i have this code
for ($x = 0; $x <= count($testas); $x += 2) {
$object = new stdClass();
$object->$testas[0] = $x;
$newArr[] = $object;
}
echo json_encode($newArr);
everything works well here, but if i chagne $testas array like this:
for ($x = 0; $x <= count($testas); $x += 2) {
$object = new stdClass();
$object->$testas[$x] = $x;
$newArr[] = $object;
}
echo json_encode($newArr);
it doesnt print out anything. Please help
Thanks
$x += 2?count($testas)(just variable) but$object->$testas[$x](object property). Are that the same array or not?