【发布时间】:2015-07-09 07:33:21
【问题描述】:
我正在处理与外部 json 页面相呼应的东西。
但是我只需要它来回显($sub = 'word'),但我的代码只是将所有$sub 重命名为'word',而不是省略那些不 = 'word' 的代码
<?php
$jsonurl = "http://site/page.json";
$json = file_get_contents($jsonurl);
$json_output = json_decode($json);
foreach ($json_output as $page) {
foreach($page->levels as $level) {
if (isset($level->sub)) {
$sub = $level->sub;
$no = $level->no;
if ($sub = 'YES!') { /*Here is the problem*/
echo $sub . '|'. 'http://site/level/' . $no . '<br />';
}
}
}}
?>
【问题讨论】:
标签: php json if-statement echo equals