php最新版本刚出的代码,可以省了好多工作量的,不用老去foreach
  1. //这个是php最新的一个数组函数
  2. $records = array(
  3. array(
  4. 'id' => 0,
  5. 'pre' => 2,
  6. 'next' => 6,
  7. ),
  8. array(
  9. 'id' => 1,
  10. 'pre' => 13,
  11. 'next' => 18,
  12. ),
  13. array(
  14. 'id' => 3,
  15. 'pre' => 3,
  16. 'next' => 8,
  17. ),
  18. array(
  19. 'id' => 4,
  20. 'pre' => 0,
  21. 'next' => 5,
  22. )
  23. );
  24. $all_pre = array_column($records, 'pre');
  25. //打印出所有的前驱节点
  26. print_r($all_pre);
  27. ?>
复制代码


08-26 15:58