3v4l.org

run code in 300+ PHP versions simultaneously
<?php $s = "client_id address address_2 city street phone phone_2 mobile mobile_2 email_2 web_address web_address_2 sex_id sex_orientation_id date_of_birth ancestry_id country_id height PRIMARY weight figure_id breast_size_id eye_color_id hair_color_id has_tattoo has_piercings body_hair_id intimate_id is_smoker is_alcoholic canton_id zip_code local_id first_name last_name text nickname"; $a = explode("\n", $s); $b = []; foreach($a as $key=>$temp) { if (strpos($temp, 'id') !== false) { $b[$temp] = [ 'valid' => 'int', 'label' => ucfirst(str_replace('_', ' ', $temp))]; } else { $b[$temp] = [ 'valid' => 'min(1)', 'label' => ucfirst(str_replace('_', ' ', $temp))]; } } var_dump($a);
Output for 7.0.0 - 7.0.23, 7.1.0 - 7.1.33, 7.2.0 - 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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
array(37) { [0]=> string(9) "client_id" [1]=> string(7) "address" [2]=> string(9) "address_2" [3]=> string(4) "city" [4]=> string(6) "street" [5]=> string(5) "phone" [6]=> string(7) "phone_2" [7]=> string(6) "mobile" [8]=> string(8) "mobile_2" [9]=> string(7) "email_2" [10]=> string(11) "web_address" [11]=> string(13) "web_address_2" [12]=> string(6) "sex_id" [13]=> string(18) "sex_orientation_id" [14]=> string(13) "date_of_birth" [15]=> string(11) "ancestry_id" [16]=> string(10) "country_id" [17]=> string(6) "height" [18]=> string(7) "PRIMARY" [19]=> string(6) "weight" [20]=> string(9) "figure_id" [21]=> string(14) "breast_size_id" [22]=> string(12) "eye_color_id" [23]=> string(13) "hair_color_id" [24]=> string(10) "has_tattoo" [25]=> string(13) "has_piercings" [26]=> string(12) "body_hair_id" [27]=> string(11) "intimate_id" [28]=> string(9) "is_smoker" [29]=> string(12) "is_alcoholic" [30]=> string(9) "canton_id" [31]=> string(8) "zip_code" [32]=> string(8) "local_id" [33]=> string(10) "first_name" [34]=> string(9) "last_name" [35]=> string(4) "text" [36]=> string(8) "nickname" }
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(37) { [0]=> string(9) "client_id" [1]=> string(7) "address" [2]=> string(9) "address_2" [3]=> string(4) "city" [4]=> string(6) "street" [5]=> string(5) "phone" [6]=> string(7) "phone_2" [7]=> string(6) "mobile" [8]=> string(8) "mobile_2" [9]=> string(7) "email_2" [10]=> string(11) "web_address" [11]=> string(13) "web_address_2" [12]=> string(6) "sex_id" [13]=> string(18) "sex_orientation_id" [14]=> string(13) "date_of_birth" [15]=> string(11) "ancestry_id" [16]=> string(10) "country_id" [17]=> string(6) "height" [18]=> string(7) "PRIMARY" [19]=> string(6) "weight" [20]=> string(9) "figure_id" [21]=> string(14) "breast_size_id" [22]=> string(12) "eye_color_id" [23]=> string(13) "hair_color_id" [24]=> string(10) "has_tattoo" [25]=> string(13) "has_piercings" [26]=> string(12) "body_hair_id" [27]=> string(11) "intimate_id" [28]=> string(9) "is_smoker" [29]=> string(12) "is_alcoholic" [30]=> string(9) "canton_id" [31]=> string(8) "zip_code" [32]=> string(8) "local_id" [33]=> string(10) "first_name" [34]=> string(9) "last_name" [35]=> string(4) "text" [36]=> string(8) "nickname" }

preferences:
222.06 ms | 405 KiB | 222 Q