-1

我有以下变量,需要在数组循环中使用它...

$jointa="'nike-score', 'pack-cupcake', 'shor-burgundy'";

foreach (array($jointa) as $id) {
    $yourSiteContent[] = array('permalink' => $id, 'updated' => $dated);
}

但是当我将值直接放在数组循环中时,它的工作正常......

foreach (array('nike-score', 'pack-cupcake', 'shor-burgundy') as $id) {
    $yourSiteContent[] = array('permalink' => $id, 'updated' => $dated);
}

请检查我在哪里做错了?

4

2 回答 2

5
$jointa = array('nike-score', 'pack-cupcake', 'shor-burgundy');

foreach ($jointa as $id) {
    $yourSiteContent[] = array('permalink' => $id, 'updated' => $dated);
}
于 2012-08-24T00:06:12.557 回答
0
$jointa = array('nike-score', 'pack-cupcake', 'shor-burgundy');


foreach ($jointa as $key => $value)
{
    echo($key . " = " . $value)
}
于 2012-08-24T00:07:11.817 回答