Blogger Information
Blog 19
fans 0
comment 0
visits 10116
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
返回数组中所有的值并给其建立从0开始递增的数字索引
bloght5386
Original
600 people have browsed it

返回数组中所有的值并给其建立从0开始递增的数字索引 $arr = [4=>10,1=>22,9=>55,0=>255]; tips: 使用函数array_values()

  1. //第一种方法使用array_value函数
  2. $arr = [4=>10,1=>22,9=>55,0=>255];
  3. print_r(array_values($arr));
  4. //第二种方法
  5. $arr_new = array();
  6. foreach ($arr as $k=>$v) {
  7. $arr_new[] = $v;
  8. //echo $v;
  9. }
  10. print_r($arr_new);
Correcting teacher:灭绝师太灭绝师太

Correction status:qualified

Teacher's comments:非常棒,学以致用~
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post