3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'client_no=100&auth_key=stEKy9vvN9mKEPTeAdNkfeuUE5CGHknB&rest_call=create_surcharge&cat=admintools-api&surcharge_name=mysurcharge1&description=description123&ext_description=description1234&currency_cd=usd&surcharge_type_cd=F&inline_offset_ind=I&apply_b4_or_after_discount_cd=B&scope_no=1&surcharge_tier[0][from]=1&surcharge_tier[0][rate]=3&plan_no[0][plan_nos]=asd&schedule[0][schedule_name]=TestSchedule1&schedule[0][currency_cd]=usd&submit=Agree & Execute'; parse_str($string, $output); var_dump($output); $rowObjectExample = ''; foreach($output as $name => $value) { if(isset($output[$name])) { if(is_array($value)) { $i = 0; $length = count($value); foreach($value as $key=>$val) { $i++; $rowObjectExample .= $name.'_row '.$name.'Row'; if($length > 1) { $rowObjectExample .= ($i <= $length ? $key : ''); } else if(is_array($val)) { $rowObjectExample .= ($i <= count($val) ? $key : ''); } $rowObjectExample .= ' = new '.$name.'_row()'.";\n\t"; if(is_array($val)) { foreach($val as $k=>$v) { if(is_array($v)) { $n = 0; $len = count($v); foreach ($v as $row=>$column) { if(is_array($column)) { $rowObjectExample .= $k.'_row '.$k.'Row'.$row.' = new '.$k.'_row()'."\n\t"; $n++; foreach($column as $r=>$c) { $rowObjectExample .= $k.'Row'; if($len > 1) { $rowObjectExample .= ($n <= $len ? $row : ''); } $rowObjectExample .= '.'.$r.' = '; $rowObjectExample .= (empty($c) ? 'null' : $c)."\n\t"; } } } } else { $rowObjectExample .= $name.'Row'; $rowObjectExample .= ($i <= count($val) ? $key : ''); $rowObjectExample .= '.'.$k.' = '.$v."\n\t"; } } } } } } } var_dump($rowObjectExample);

preferences:
53.24 ms | 402 KiB | 5 Q