Original way of writing, returning a certain column or several columns of the array

WBOY
Release: 2016-07-25 08:51:05
Original
1061 people have browsed it
The code just released in the latest version of php can save a lot of work, and you don’t have to go to foreach
  1. //Get record data
  2. //This is the latest array function of PHP
  3. $records = array(
  4. array(
  5. 'id' => 0,
  6. 'pre' => ; 2,
  7. 'next' => 6,
  8. ),
  9. array(
  10. 'id' => 1,
  11. 'pre' => 13,
  12. 'next' => 18,
  13. ),
  14. array (
  15. 'id' => 3,
  16. 'pre' => 3,
  17. 'next' => 8,
  18. ),
  19. array(
  20. 'id' => 4,
  21. 'pre' => 0,
  22. 'next' => 5,
  23. )
  24. );
  25. $all_pre = array_column($records, 'pre');
  26. //Print out all predecessor nodes
  27. print_r($all_pre);
  28. ?> ;
Copy code


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