是否有内置的 php 函数或将元素插入到数组开头的简单方法?
就像是:
$matches = Array("apples", "oranges");
insert_to_beginning($matches, "peach");
内容:
$matches[0] = peach
$matches[1] = apples
$matches[2] = oranges
是否有内置的 php 函数或将元素插入到数组开头的简单方法?
就像是:
$matches = Array("apples", "oranges");
insert_to_beginning($matches, "peach");
内容:
$matches[0] = peach
$matches[1] = apples
$matches[2] = oranges
array_unshift
是您正在寻找的功能。
array_unshift($matches, "peach");
array_unshift($matches, 'peach');