Home > Backend Development > PHP Tutorial > 二维数组怎么值

二维数组怎么值

WBOY
Release: 2016-06-13 13:51:00
Original
975 people have browsed it

二维数组如何值
比方说现在有个数组
$a=array(
  array(a=>1),
  array(a=>2),
  array(a=>3),
);
我现在就想要数组里面的前两个

变成
$a=array(
  array(a=>1),
  array(a=>2),
);
应该怎样实现


------解决方案--------------------
$a=array( 
array(a=> 1), 
array(a=> 2), 
array(a=> 3), 
); 
$a = array_splice($a, 0, 2);
echo var_dump($a);
?>

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