我试图让我的 foreach 根据其中一个孩子的价值观跳过 xml 中的某些孩子。第一个代码仅用于跳过 1,但我想跳过很多。第二个代码不会跳过任何一个。
<?php
$gamespage = simplexml_load_file("http://gamepage.com/games?xml=1");
foreach($gamespage->games->game as $game)
{
$gid = $game->appID;
if ($gid != 65920) {
} }
第二个代码(不跳过任何代码):
<?php
$gamespage = simplexml_load_file("http://gamepage.com/games?xml=1");
foreach($gamespage->games->game as $game)
{
$gid = $game->appID;
if ($gid != 65920 || $gid != 40940 || $gid != 50110 || $gid != 8990) {
} }