3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr=array( array( array(array( "value1", "value2" ), "value2" ), array( "value3", "value4" ) ), array( array( "value5", "value6" ), array( "value7", "value8" ) ) ); var_debug($arr); function var_debug($variable,$strlen=100,$width=25,$depth=10,$i=0,&$objects = array()) { $search = array("\0", "\a", "\b", "\f", "\n", "\r", "\t", "\v"); $replace = array('\0', '\a', '\b', '\f', '\n', '\r', '\t', '\v'); $string = ''; switch(gettype($variable)) { case 'boolean': $string.= $variable?'true':'false'; break; case 'integer': $string.= $variable; break; case 'double': $string.= $variable; break; case 'resource': $string.= '[resource]'; break; case 'NULL': $string.= "null"; break; case 'unknown type': $string.= '???'; break; case 'string': $len = strlen($variable); $variable = str_replace($search,$replace,substr($variable,0,$strlen),$count); $variable = substr($variable,0,$strlen); if ($len<$strlen) $string.= '"'.$variable.'"'; else $string.= 'string('.$len.'): "'.$variable.'"...'; break; case 'array': $len = count($variable); if ($i==$depth) $string.= 'array('.$len.') {...}'; elseif(!$len) $string.= 'array(0) {}'; else { $keys = array_keys($variable); $spaces = str_repeat(' ',$i*2); $string.= "array($len)\n".$spaces.'{'; $count=0; foreach($keys as $key) { if ($count==$width) { $string.= "\n".$spaces." ..."; break; } $string.= "\n".$spaces." [$key] => "; $string.= var_debug($variable[$key],$strlen,$width,$depth,$i+1,$objects); $count++; } $string.="\n".$spaces.'}'; } break; case 'object': $id = array_search($variable,$objects,true); if ($id!==false) $string.=get_class($variable).'#'.($id+1).' {...}'; else if($i==$depth) $string.=get_class($variable).' {...}'; else { $id = array_push($objects,$variable); $array = (array)$variable; $spaces = str_repeat(' ',$i*2); $string.= get_class($variable)."#$id\n".$spaces.'{'; $properties = array_keys($array); foreach($properties as $property) { $name = str_replace("\0",':',trim($property)); $string.= "\n".$spaces." [$name] => "; $string.= var_debug($array[$property],$strlen,$width,$depth,$i+1,$objects); } $string.= "\n".$spaces.'}'; } break; } if ($i>0) return $string; $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); do $caller = array_shift($backtrace); while ($caller && !isset($caller['file'])); if ($caller) $string = $caller['file'].':'.$caller['line']."\n".$string; echo $string; }
Output for 7.1.25 - 7.1.30, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.4 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
/in/aCmrD:14 array(2) { [0] => array(2) { [0] => array(2) { [0] => array(2) { [0] => "value1" [1] => "value2" } [1] => "value2" } [1] => array(2) { [0] => "value3" [1] => "value4" } } [1] => array(2) { [0] => array(2) { [0] => "value5" [1] => "value6" } [1] => array(2) { [0] => "value7" [1] => "value8" } } }
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
206.37 ms | 407 KiB | 5 Q