<?php
<?php
$resdata = array(
array(
array(
"prefix" => 93,
"rate" => "0.172962000",
"destination" => "Afghanistan"
)
),
array(
array(
"prefix" => 9320,
"rate" => 0,
"destination" => "Afghanistan (ON-NET)"
)
),
array(
array(
"prefix" => 9350,
"rate" => 0,
"destination" => "Afghanistan (ON-NET)"
)
),
array(
array(
"prefix" => 935,
"rate" => "0.451478000",
"destination" => "Afghanistan (ON-NET)"
)
),
array(
array(
"prefix" => 9360,
"rate" => 0,
"destination" => "Afghanistan (ON-NET)"
)
)
);
function getRate($items, $prefix) {
while($prefix = $prefix/10) {
foreach ($items as $key => $value) {
if ($value[0]["prefix"] === (int)$prefix) {
return $value[0]["rate"];
}
}
}
return null;
};
foreach ($resdata as $key => $row) {
if($row[0]['rate'] === 0) {
$rate = getRate($resdata, $row[0]['prefix']);
if ($rate) {
$resdata[$key][0]['rate'] = $rate;
}
}
}
print_r($resdata);
- Output for 7.0.0
- Parse error: syntax error, unexpected '<', expecting end of file in /in/7adVc on line 3
Process exited with code 255. - Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.16
- Parse error: syntax error, unexpected '<' in /in/7adVc on line 3
Process exited with code 255.
preferences:
169.17 ms | 1395 KiB | 24 Q