Reputation: 27
$cInc = json_decode($inc);
$c = count((array)$cInc);
for ($x = 0; $x < $c; $x++)
{
$section->addListItem($cInc[$x]);
}
So I want to loop the array $cInc
to a List Item and somehow the loop corrupts the document.
Upvotes: 0
Views: 70
Reputation: 538
i think you are wrong using count
The count() function returns the number of elements in an array
so you dont need array inside count
just
$cInc = json_decode($inc);
$c = count($cInc);
for ($x = 0; $x < $c; $x++)
{
$section->addListItem($cInc[$x]);
}
or u can use foreach if you dont know how many array that you have
$cInc = json_decode($inc);
foreach ($cInc as $val)
{
$section->addListItem($val);
}
Upvotes: 1