3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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))]; } } echo $a;
based on lepTa
Output for 5.6.0 - 5.6.30, hhvm-3.18.4 - 3.21.0, 7.0.0 - 7.3.0beta1
Notice: Array to string conversion in /in/a5Wnq on line 49 Array