3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ "id" => 54, "type" => 5, "content" => [ ["id" => 99, "type" => 516], ["id" => 88, "type" => 464], ["id" => 41, "type" => 845] ] ], [ "id" => 54, "type" => 55, "content" => [ ["id" => 54, "type" => 578], ["id" => 54, "type" => 354], ["id" => 75, "type" => 458] ] ], [ "id" => 65, "type" => 59, "content" => [ ["id" => 87, "type" => 5454], ["id" => 65, "type" => 245], ["id" => 65, "type" => 24525] ] ] ]; $id = 54; $type = 55; foreach ($array as &$row) { if ($row["id"] == $id && $row["type"] == $type) { $ref = &$row["content"]; } } $ref = 'this has been changed'; var_export($array);
Output for 7.3.13 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.4, 8.3.6 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
array ( 0 => array ( 'id' => 54, 'type' => 5, 'content' => array ( 0 => array ( 'id' => 99, 'type' => 516, ), 1 => array ( 'id' => 88, 'type' => 464, ), 2 => array ( 'id' => 41, 'type' => 845, ), ), ), 1 => array ( 'id' => 54, 'type' => 55, 'content' => 'this has been changed', ), 2 => array ( 'id' => 65, 'type' => 59, 'content' => array ( 0 => array ( 'id' => 87, 'type' => 5454, ), 1 => array ( 'id' => 65, 'type' => 245, ), 2 => array ( 'id' => 65, 'type' => 24525, ), ), ), )
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 array ( 0 => array ( 'id' => 54, 'type' => 5, 'content' => array ( 0 => array ( 'id' => 99, 'type' => 516, ), 1 => array ( 'id' => 88, 'type' => 464, ), 2 => array ( 'id' => 41, 'type' => 845, ), ), ), 1 => array ( 'id' => 54, 'type' => 55, 'content' => 'this has been changed', ), 2 => array ( 'id' => 65, 'type' => 59, 'content' => array ( 0 => array ( 'id' => 87, 'type' => 5454, ), 1 => array ( 'id' => 65, 'type' => 245, ), 2 => array ( 'id' => 65, 'type' => 24525, ), ), ), )

preferences:
68.74 ms | 1494 KiB | 4 Q