PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $arr = [1=>"A", 2 => "B", 6 => "Z"]; $un = ["G", "H", "I"]; $length = count($arr) + count($un); for ($i = 1; $i <= $length; $i++) { if (!array_key_exists($i, $arr)) $arr[$i] = array_shift($un); } ksort($arr); $res = array(); $res[] = array_values ($arr); echo json_encode($res);
Show:  
Copy Clear