PHPize Online / SQLize Online

A A A
Share   Donate   Blog   Popular
Copy Format Clear
Copy
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); } $res = array(); $res[] = $arr; echo json_encode($res);
Show:  
Copy