Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将数组的特定项放在它的末尾_Php_Arrays - Fatal编程技术网

Php 将数组的特定项放在它的末尾

Php 将数组的特定项放在它的末尾,php,arrays,Php,Arrays,我想选择一个PHP数组的特定项,并将其放在数组的末尾。我的数组由未知数量的项组成(即,您事先不知道将有多少项),我想选择一个带有键Other的项,并将其放置在数组的末尾 我用数组_diff()尝试了一些,但我无法选择其他项。我可以在foreach循环中使用Other-键选择并取消设置该项,但无法将其放置在数组的末尾。所以任何建议都很好。你能发布样本数组吗?你能发布样本数组吗?就这么简单,但我没有看到。谢谢你的回答!就这么简单,但我没有看到。谢谢你的回答! $tmp = $array['Other

我想选择一个PHP数组的特定项,并将其放在数组的末尾。我的数组由未知数量的项组成(即,您事先不知道将有多少项),我想选择一个带有键
Other
的项,并将其放置在数组的末尾


我用
数组_diff()
尝试了一些,但我无法选择
其他
项。我可以在foreach循环中使用
Other
-键选择并取消设置该项,但无法将其放置在数组的末尾。所以任何建议都很好。

你能发布样本数组吗?你能发布样本数组吗?就这么简单,但我没有看到。谢谢你的回答!就这么简单,但我没有看到。谢谢你的回答!
$tmp = $array['Other'];
unset($array['Other']);
$array['Other'] = $tmp;
$array = array(
    'one' => 'some value',
    'other' => 'some value',
    'two' => 'some value',
    'three' => 'some value',
);



$other = $array['other'];
unset($array['other']);
$array['other'] = $other;
$arr = array( 'key' => 'test', 'other' => 'test2', 'key2' => 'test3' );

$arr_other = $arr['other']; 

unset( $arr['other'] );

$arr['other'] = $arr_other;

print_r($arr);