曾今写过一个坑货的数组方法

 

 function array_insert($myarray,$value,$position=0)
 {
    $fore=($position==0)?array():array_splice($myarray,0,$position);
    $fore[]=$value;
    $ret=array_merge($fore,$myarray);
    return $ret;
 }

此函数用法
返回一个数组,内容是在$myarray数组的$position处插入$value
例如
$a=array("a", "b","c", "d");
$a=array_insert($a,"add",3);
print_r($a); //Array ( [0] => a [1] => b [2] => c [3] => add [4] => d )

相关文章:

  • 2021-12-01
  • 2022-02-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-06
  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
  • 2022-01-02
  • 2022-12-23
相关资源
相似解决方案