Blogger Information
Blog 34
fans 0
comment 0
visits 20274
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php灭绝手把手亲传数组索引重建
小庄
Original
462 people have browsed it

php灭绝手把手亲传数组索引重建

  1. <?php
  2. // 返回数组中所有的值并给其建立从0开始递增的数字索引
  3. $arr = [4=>10,1=>22,9=>55,0=>255];
  4. echo '<pre>';
  5. echo '原数组';
  6. var_dump($arr);
  7. echo 'array_values返回的数组<br />';
  8. var_dump(array_values($arr));
  9. $arr_str = [];
  10. foreach ($arr as $k => $v){
  11. $arr_str[] = $v;
  12. }
  13. echo 'foreach也可以做到<br />';
  14. var_dump($arr_str);
Correcting teacher:PHPzPHPz

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!