Home > Backend Development > PHP Tutorial > 请问 要求x包含y,x按y排序

请问 要求x包含y,x按y排序

WBOY
Release: 2016-06-13 12:32:36
Original
1148 people have browsed it

请教 要求x包含y,x按y排序
怎么说呢,其实就是要求x包含y,x按y排序

比较x和y两个数组,
如果x长度大于y,则将x数组中多出的键追加到y数组后面
例如:
$x = array(0=>'a', 1=>'b', 2=>'c', 3=>'d', 4=>'e');
$y = array(2=>'c', 4=>'e', 0=>'a');
则结果为 array(2=>'c', 4=>'e', 0=>'a',   1=>'b', 3=>'d');

如果x长度小于y,则先将y数组中多出的键删除
$x = array(0=>'a', 1=>'b');
$y = array(2=>'c', 4=>'e', 0=>'a');
则结果为 array(0=>'a', 1=>'b');

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template