我在将对象推入数组时遇到问题。
这是我的对象
Products Object
(
[id] =>
[title] => Titel
[articlenumber] => Artikelnummer
[price] => Prijs
[sale_price] => Sale Prijs
[description] => Tekst
[views] => 1
[brand] => Merk
[soled] => 0
[start_date] => 2011-04-21
[end_date] => 2011-04-28
[active] => 2
[sale_text] => Sale Tekst
)
这是我的数组,我试图将所有内容推送到数组
Array
(
[0] => title, Titel
[1] => articlenumber, Artikelnummer
[2] => price, Prijs
[3] => sale_price, Sale Prijs
[4] => description, Tekst
[5] => views, 1
[6] => brand, Merk
)
正如您所看到的,当他谈到“soled”项目时,我的代码停止了,因为值为 0。当我将此值设置为其他值时,如果工作正常。
这是我使用的代码。
$value = array();
while (next($Product)) {
$constant = key($Product);
array_push($value, $constant.", ".$Product->$constant);
echo $constant."<br>";
}