Heim  >  Artikel  >  Backend-Entwicklung  >  原生态,返回数组的的某一列或者某几列的的写法

原生态,返回数组的的某一列或者某几列的的写法

WBOY
WBOYOriginal
2016-07-25 08:51:051003Durchsuche
php最新版本刚出的代码,可以省了好多工作量的,不用老去foreach
  1. // 获得纪录的数据
  2. //这个是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. //打印出所有的前驱节点
  27. print_r($all_pre);
  28. ?>
复制代码


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn