/* XMLファイルの内容を取得 */
$tenki = simplexml_load_file('http://tenki.wet.co.jp/forecast/day01ymg.rdf'); // ブログタイトル取得
echo $tenki->channel->title."
\n";
// ブログ説明取得
echo $tenki->channel->description."
\n";
for($i = 0; $i < 5; $i++) {
// 記事のタイトル取得
$title = $tenki->channel->item[$i]->title;}
// HTML整形
echo $title;
?>
/* XMLファイルの内容を取得 */
$rss = simplexml_load_file('http://tenki.wet.co.jp/forecast/day01ymg.rdf');
foreach ($rss->channel->item as $title){
$title = $rss->channel->item->title;
if(ereg("村山", $title)){
echo $rss->channel->item->title."
\n";
break;
}
}
?>
/* RDFファイルを取得 */
$rss = simplexml_load_file('http://tenki.wet.co.jp/forecast/day01ymg.rdf');
/* RDFに書かれている特定の地方を記述 */
$area = "村山";
/* RDFに書かれている天候を記述 */
global $weather = "晴|曇|雨|雪|霧";
/* 初期化 */
$value=0;
foreach ($rss->channel->item as $title){
$title = $rss->channel->item->title;
if(ereg("$area", $title)){
$strlen = mb_strlen($title);
while ($strlen) {
$array[] = mb_substr($title,0,1,"UTF-8");
$title = mb_substr($title,1,$strlen,"UTF-8");
$strlen = mb_strlen($title);
}
break;
}
}
for($i=0; $i<count($array); $i++ ){
if(ereg("$weather",$array[$i])){
$dayforecast[$value]=$array[$i];
$value++;
}
}
echo "今日午前".$dayforecast[0]."<hr />";
echo "今日午後".$dayforecast[1]."
";
echo "明日午前".$dayforecast[2]."
";
echo "明日午後".$dayforecast[3]."
";
?>
/* RDFファイルを取得 */
$rss = simplexml_load_file('http://tenki.wet.co.jp/forecast/day01ymg.rdf');
/* RDFに書かれている特定の地方を記述 */
$area = "村山";
/* RDFに書かれている天候を記述 */
$weather = "晴|曇|雨|雪|霧|雷";
/* 掲載するホームページ */
$url = "http://localhost/jidaiya/";
/* 初期化 */
$value=0;$time=0;
foreach ($rss->channel->item as $title){
$title = $rss->channel->item->title;
if(ereg("$area", $title)){
$strlen = mb_strlen($title);
while ($strlen) {
$array[] = mb_substr($title,0,1,"UTF-8");
$title = mb_substr($title,1,$strlen,"UTF-8");
$strlen = mb_strlen($title);
}
break;
}
}
for($i=0; $i<count($array); $i++ ){
if(ereg("$weather",$array[$i])){
$dayforecast[$value]=$array[$i];
$value++;
}
}
echo timecheak($array).imgchange($dayforecast[0],$url)."<hr />";
echo timecheak($array).imgchange($dayforecast[1],$url)."
";
echo "明日午前".imgchange($dayforecast[2],$url)."
";
echo "明日午後".imgchange($dayforecast[3],$url)."
";
echo "明後日午前".imgchange($dayforecast[4],$url)."
";
echo "明後日午後".imgchange($dayforecast[5],$url)."
";
function timecheak($arr){
for($i=0; $i<count($arr); $i++ ){
if(ereg("夜",$arr[$i])){
return $time="今夜";
break;
}
}
return $time="今日";
}
function imgchange($text,$url){
switch ($text){
case '晴':return $wetherimage=$url."/wether-img/1.gif";break;
case '曇':return $wetherimage=$url."/wether-img/2.gif";break;
case '雨':return $wetherimage=$url."/wether-img/3.gif";break;
case '雪':return $wetherimage=$url."/wether-img/4.gif";break;
case '霧':return $wetherimage=$url."/wether-img/5.gif";break;
case '雷':return $wetherimage=$url."/wether-img/7.gif";break;
default:$wetherimage='未登録の天候です';break;
}
}
?>
/* RDFファイルを取得 */
$rss = simplexml_load_file('http://tenki.wet.co.jp/forecast/day01ymg.rdf');
/* RDFに書かれている特定の地方を記述 */
$area = "村山";
/* RDFに書かれている天候を記述 */
$weather = "晴|曇|雨|雪|霧|雷";
/* 掲載するホームページ */
$url = "http://localhost/jidaiya/";
//基本的な変更終了!↓触らなくてもOK!
/* 初期化 */
$value=0;$time=0;
foreach ($rss->channel->item as $title){
$title = $rss->channel->item->title;
if(ereg("$area", $title)){
$strlen = mb_strlen($title);
while ($strlen) {
$array[] = mb_substr($title,0,1,"UTF-8");
$title = mb_substr($title,1,$strlen,"UTF-8");
$strlen = mb_strlen($title);
}
break;
}
}
for($i=0; $i<count($array); $i++ ){
if(ereg("$weather",$array[$i])){
$dayforecast[$value]=$array[$i];
$value++;
}
}
/*このecho関数で情報を吐き出します。CSSの変更などを加えたいときはここを触るといいかも?
自分もよくわかっていませんが、連絡いただければご一緒に悩んでみます:-)*/
echo "<ul>\n
".timecheak($array).imgchange($dayforecast[0],$url)." / ".imgchange($dayforecast[1],$url)."\n";
echo "
明日".imgchange($dayforecast[2],$url)." / ".imgchange($dayforecast[3],$url)."\n";
echo "
明後日".imgchange($dayforecast[4],$url)." / ".imgchange($dayforecast[5],$url)."\n\n";
function timecheak($arr){
for($i=0; $i<count($arr); $i++ ){
if(ereg("夜",$arr[$i])){
return $time="今夜";
break;
}
}
return $time="今日";
}
function imgchange($text,$url){
switch ($text){
case '晴':return $wetherimage="<img src=\"".$url."/wether-img/1.gif\" alt=\"晴れ\"/>";break;
case '曇':return $wetherimage="
";break;
case '雨':return $wetherimage="
";break;
case '雪':return $wetherimage="
";break;
case '霧':return $wetherimage="
";break;
case '雷':return $wetherimage="
";break;
default:$wetherimage='未登録の天候です';break;
}
}
?>
/* RDFファイルを取得 */
$rss = simplexml_load_file('http://tenki.wet.co.jp/forecast/day01ymg.rdf');
/* RDFに書かれている特定の地方を記述 */
$area = "村山";
/* RDFに書かれている天候を記述 */
$weather = "晴|曇|止|雨|雪|霧|雷";
/* 掲載するホームページ */
$url = "http://localhost/jidaiya/";
//基本的な変更終了!↓触らなくてもOK!
/* 初期化 */
$value=0;$time=0;
foreach ($rss->channel->item as $title){
$title = $rss->channel->item->title;
if(ereg("$area", $title)){
$strlen = mb_strlen($title);
while ($strlen) {
$array[] = mb_substr($title,0,1,"UTF-8");
$title = mb_substr($title,1,$strlen,"UTF-8");
$strlen = mb_strlen($title);
}
break;
}
}
for($i=0; $i<count($array); $i++ ){
if(ereg("$weather",$array[$i])){
$dayforecast[$value]=$array[$i];
$value++;
}
}
/*このecho関数で情報を吐き出します。CSSの変更などを加えたいときはここを触るといいかも?
自分もよくわかっていませんが、連絡いただければご一緒に悩んでみます:-)*/
echo "<ul>\n
".timecheak($array).imgchange($dayforecast[0],$url)." / ".imgchange($dayforecast[1],$url)."\n";
echo "
明日".imgchange($dayforecast[2],$url)." / ".imgchange($dayforecast[3],$url)."\n";
echo "
明後日".imgchange($dayforecast[4],$url)." / ".imgchange($dayforecast[5],$url)."\n\n";
function timecheak($arr){
for($i=0; $i<count($arr); $i++ ){
if(ereg("夜",$arr[$i])){
return $time="今夜";
break;
}
}
return $time="今日";
}
function imgchange($text,$url){
switch ($text){
case '晴':return $wetherimage="<img src=\"".$url."/wether-img/1.gif\" alt=\"晴れ\"/>";break;
case '曇':return $wetherimage="
";break;
case '止':return $wetherimage="
";break;
case '雨':return $wetherimage="
";break;
case '雪':return $wetherimage="
";break;
case '霧':return $wetherimage="
";break;
case '雷':return $wetherimage="
";break;
default:$wetherimage='未登録の天候です';break;
}
}
?>
/* RDFファイルを取得 */
$rss = simplexml_load_file('http://tenki.wet.co.jp/forecast/day01ymg.rdf');
/* RDFに書かれている特定の地方を記述 */
$area = "村山";
/* RDFに書かれている天候を記述 */
$weather = "晴|曇|止|雨|雪|霧|雷";
/* 掲載するホームページ */
$url = "http://localhost/jidaiya/";
//基本的な変更終了!↓触らなくてもOK!
/* 初期化 */
$value=0;$time=0;$DAT=0;
foreach ($rss->channel->item as $title){
$title = $rss->channel->item->title;
if(ereg("$area", $title)){
if(ereg("〔.+〕", $title)){
}else{
if(!ereg("明後日", $title)){$DAT=1;}
$strlen = mb_strlen($title);
while ($strlen) {
$array[] = mb_substr($title,0,1,"UTF-8");
$title = mb_substr($title,1,$strlen,"UTF-8");
$strlen = mb_strlen($title);
}
break;
}
}
for($i=0; $i<count($array); $i++ ){
if(ereg("$weather",$array[$i])){
$dayforecast[$value]=$array[$i];
$value++;
}
}
/*このecho関数で情報を吐き出します。CSSの変更などを加えたいときはここを触るといいかも?
自分もよくわかっていませんが、連絡いただければご一緒に悩んでみます:-)*/
echo "<ul>\n
".timecheak($array).imgchange($dayforecast[0],$url)." / ".imgchange($dayforecast[1],$url)."\n";
echo "
明日".imgchange($dayforecast[2],$url)." / ".imgchange($dayforecast[3],$url)."\n";
if($DAT=0){echo "
明後日".imgchange($dayforecast[4],$url)." / ".imgchange($dayforecast[5],$url)."\n\n";}
function timecheak($arr){
for($i=0; $i<count($arr); $i++ ){
if(ereg("夜",$arr[$i])){
return $time="今夜";
break;
}
}
return $time="今日";
}
function imgchange($text,$url){
switch ($text){
case '晴':return $wetherimage="<img src=\"".$url."/wether-img/1.gif\" alt=\"晴れ\"/>";break;
case '曇':return $wetherimage="
";break;
case '止':return $wetherimage="
";break;
case '雨':return $wetherimage="
";break;
case '雪':return $wetherimage="
";break;
case '霧':return $wetherimage="
";break;
case '雷':return $wetherimage="
";break;
default:$wetherimage='未登録の天候です';break;
}
}
?>
/* RDFファイルを取得 */
$rss = simplexml_load_file('http://tenki.wet.co.jp/forecast/day01ymg.rdf');
/* RDFに書かれている特定の地方を記述 */
$area = "村山";
/* 掲載するホームページ */
$url = "http://localhost/jidaiya/";
//基本的な変更終了!↓触らなくてもOK!
/* RDFに書かれている天候を記述 */
$weather = "晴|曇|止|雨|雪|霧|雷";
/* 初期化 */
$AT=0;$DAT=0;$out=0;$loop=0;$analyze=0;
foreach ($rss->channel->item as $title){
$title = $rss->channel->item->title;
if(ereg("$area", $title)){
if(ereg("明日", $title)){$AT=1;}
if(ereg("明後日", $title)){$DAT=1;}
preg_match_all("|〔(.*)〕|U","$title",$out, PREG_PATTERN_ORDER);
break;
}
}
for($i=0;$i<3;$i++){
$analyze=lyze($out[1][$i],$weather,$i);
echo $out[1][i]."<br />";
for($j=0;$j<2;$j++){
$wetherinfo[$loop]=$analyze[$j];
$loop++;
}
}
/*このecho関数でHTMLを吐き出します。CSSの変更などを加えたいときはここを触るといいかも?
自分もよくわかっていませんが、連絡いただければご一緒に悩んでみます:-)*/
?>
- ".timecheak($title).imgchange($wetherinfo[0],$url)." / ".imgchange($wetherinfo[1],$url)."
\n";
if($AT=1){echo "- 明日".imgchange($wetherinfo[2],$url)." / ".imgchange($wetherinfo[3],$url)."
\n";}
if($DAT=1){echo "- 明後日".imgchange($wetherinfo[4],$url)." / ".imgchange($wetherinfo[5],$url)."
\n";}
?>
<?php
function lyze($text,$weather,$value){
$flag=0;
$strlen = mb_strlen($text);
while ($strlen) {
$array[] = mb_substr($text,0,1,"UTF-8");
$text = mb_substr($text,1,$strlen,"UTF-8");
$strlen = mb_strlen($text);
}
if(count($array)==1){
if($value==0){$dayforecast[0]=$array[0];$dayforecast[1]=$array[0];return $dayforecast;}
if($value==1){$dayforecast[2]=$array[0];$dayforecast[3]=$array[0];return $dayforecast;}
if($value==2){$dayforecast[4]=$array[0];$dayforecast[5]=$array[0];return $dayforecast;}
}else{
for($i=0; $i<count($array); $i++ ){
if(ereg("$weather",$array[$i])){
$dayforecast[$flag]=$array[$i];
$flag++;
}
}
return $dayforecast;
}
}
function timecheak($text){
if(ereg("今夜",$text)){
return $time = "今夜" ;
}else{
return $time = "今日" ;
}
}
function imgchange($text,$url){
switch ($text){
case '晴':return $wetherimage="<img src=\"".$url."/wether-img/1.gif\" alt=\"晴れ\"/>";break;
case '曇':return $wetherimage="
";break;
case '止':return $wetherimage="
";break;
case '雨':return $wetherimage="
";break;
case '雪':return $wetherimage="
";break;
case '霧':return $wetherimage="
";break;
case '雷':return $wetherimage="
";break;
default:$wetherimage='未登録の天候です';break;
}
}
?>