您好,欢迎访问一九零五行业门户网

完善以下PHP代码中的insertAt函数,实现在数组$items的任意位置插入数据

string '橙子' (length=6) 3 => string '梨' (length=3) 4 => string '菠萝' (length=6) 5 => string '香蕉' (length=6) 6 => string '火龙果' (length=9) */
@宋小北 提到的array_splice是php原生实现。我们千万不要重复造轮子。
这里造一个,仅为了好玩。
function insertat($items, $value, $index=0) { is_numeric($index) and $items[($index-'0.1').'x'] = $value and ksort($items); return array_values($items);}
其它类似信息

推荐信息