3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = array( 'gid'=>1, 'phone_number'=>1, 'weibo'=>1, 'qq'=>1, 'email'=>1, 'gender'=>1, 'age'=>1, 'area'=>1, 'computer'=>1, 'phone'=>1, 'valid_user'=>1, 'bank'=>json_encode(array(1,2,3)), 'tag_big'=>json_encode(array(1,2,3)), 'tag_medium'=>json_encode(array(1,2,3)), 'tag_small'=>json_encode(array(1,2,3)), 'family'=>json_encode(array(1,2,3)), 'friend'=>json_encode(array(1,2,3)), 'visitor'=>json_encode(array(1,2,3)) ); $field = array( 'gid', 'phone_number', 'weibo', 'qq', 'email', 'gender', 'age', 'area', 'computer', 'phone', 'valid_user', 'bank', 'tag_big', 'tag_medium', 'tag_small', 'family', 'friend', 'visitor' ); function constructPortrait($field, $test){ $retPortraitArr = array(); $portraitArr = array($test); $func = function($field,$portrait) { return empty($portrait) ? 'st' : $portrait; }; foreach($portraitArr as $key => $portrait){ $retPortraitArr = array_map($func , $field, $portrait); } return $retPortraitArr; } echo json_encode(constructPortrait($field, $test));
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.17 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
[1,1,1,1,1,1,1,1,1,1,1,"[1,2,3]","[1,2,3]","[1,2,3]","[1,2,3]","[1,2,3]","[1,2,3]","[1,2,3]"]
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 [1,1,1,1,1,1,1,1,1,1,1,"[1,2,3]","[1,2,3]","[1,2,3]","[1,2,3]","[1,2,3]","[1,2,3]","[1,2,3]"]

preferences:
206.4 ms | 402 KiB | 248 Q