3v4l.org

run code in 300+ PHP versions simultaneously
<?php function &getRowReference($array, $fn) { foreach ($array as $row) { if ($fn($row)) { return $row->content; } } } function qualifyingRow($row) { global $id; global $type; return $row->id == $id && $row->type == $type; } $id = 54; $type = 55; $array = [ (object)[ "id" => 54, "type" => 5, "content" => [ ["id" => 99, "type" => 516], ["id" => 88, "type" => 464], ["id" => 41, "type" => 845] ] ], (object)[ "id" => 54, "type" => 55, "content" => [ ["id" => 54, "type" => 578], ["id" => 54, "type" => 354], ["id" => 75, "type" => 458] ] ], (object)[ "id" => 65, "type" => 59, "content" => [ ["id" => 87, "type" => 5454], ["id" => 65, "type" => 245], ["id" => 65, "type" => 24525] ] ] ]; $ref = &getRowReference($array, 'qualifyingRow'); $ref = 'this has been changed'; var_export($array);

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
165.23 ms | 2130 KiB | 10 Q