<?php
$string = 'client_no=100&auth_key=stEKy9vvN9mKEPTeAdNkfeuUE5CGHknB&rest_call=create_surcharge&cat=admintools-api&surcharge_name=mysurcharge1&description=description123&ext_description=description1234¤cy_cd=usd&surcharge_type_cd=F&inline_offset_ind=I&apply_b4_or_after_discount_cd=B&scope_no=1&surcharge_tier%5B0%5D%5Bfrom%5D=1&surcharge_tier%5B0%5D%5Brate%5D=3&surcharge_tier%5B1%5D%5Bfrom%5D=2&surcharge_tier%5B1%5D%5Brate%5D=4&plan_no%5B0%5D%5Bplan_nos%5D=asd&schedule%5B0%5D%5Bschedule_name%5D=TestSchedule1&schedule%5B0%5D%5Bcurrency_cd%5D=usd&submit=Agree+%26+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);
- Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0 - 7.2.33, 7.3.16 - 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.7
- array(16) {
["client_no"]=>
string(3) "100"
["auth_key"]=>
string(32) "stEKy9vvN9mKEPTeAdNkfeuUE5CGHknB"
["rest_call"]=>
string(16) "create_surcharge"
["cat"]=>
string(14) "admintools-api"
["surcharge_name"]=>
string(12) "mysurcharge1"
["description"]=>
string(14) "description123"
["ext_description"]=>
string(15) "description1234"
["currency_cd"]=>
string(3) "usd"
["surcharge_type_cd"]=>
string(1) "F"
["inline_offset_ind"]=>
string(1) "I"
["apply_b4_or_after_discount_cd"]=>
string(1) "B"
["scope_no"]=>
string(1) "1"
["surcharge_tier"]=>
array(2) {
[0]=>
array(2) {
["from"]=>
string(1) "1"
["rate"]=>
string(1) "3"
}
[1]=>
array(2) {
["from"]=>
string(1) "2"
["rate"]=>
string(1) "4"
}
}
["plan_no"]=>
array(1) {
[0]=>
array(1) {
["plan_nos"]=>
string(3) "asd"
}
}
["schedule"]=>
array(1) {
[0]=>
array(2) {
["schedule_name"]=>
string(13) "TestSchedule1"
["currency_cd"]=>
string(3) "usd"
}
}
["submit"]=>
string(15) "Agree & Execute"
}
string(449) "surcharge_tier_row surcharge_tierRow0 = new surcharge_tier_row();
surcharge_tierRow0.from = 1
surcharge_tierRow0.rate = 3
surcharge_tier_row surcharge_tierRow1 = new surcharge_tier_row();
surcharge_tierRow1.from = 2
surcharge_tierRow1.rate = 4
plan_no_row plan_noRow0 = new plan_no_row();
plan_noRow0.plan_nos = asd
schedule_row scheduleRow0 = new schedule_row();
scheduleRow0.schedule_name = TestSchedule1
scheduleRow0.currency_cd = usd
"
preferences:
228.1 ms | 409 KiB | 310 Q