i want to convert a stdClass object to string and reduce an array with the max value from the stdClass object.
This is my array:
Array
(
[135] => Array
(
[0] => stdClass Object
(
[ID] => 145
)
[1] => stdClass Object
(
[ID] => 138
)
[2] => stdClass Object
(
[ID] => 139
)
)
[140] => Array
(
[0] => stdClass Object
(
[ID] => 163
)
[1] => stdClass Object
(
[ID] => 155
)
)
Basically it should look like this:
Array
(
[135] => 139
[140] => 164
)
Is this possible? I've tried various foreach loops but i don't get it with the stdClass object...
My try so far:
foreach($ids as $k => $v) {
for($i = 0; $i < count($v); $i++) {
$idss[$i] = array()$v;
}
}
That doesn't work.
Thanks alot in advance! You would be my life saver today.
Best regards
json_encode()
and then decode it back with the second parameter set totrue
:$output = json_decode(json_encode($input), true);
– HamZa May 11 at 21:07