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
- //Get record data
- //This is the latest array function of PHP
- $records = array(
- array(
- 'id' => 0,
- 'pre' => ; 2,
- 'next' => 6,
- ),
- array(
- 'id' => 1,
- 'pre' => 13,
- 'next' => 18,
- ),
- array (
- 'id' => 3,
- 'pre' => 3,
- 'next' => 8,
- ),
- array(
- 'id' => 4,
- 'pre' => 0,
- 'next' => 5,
- )
- );
-
- $all_pre = array_column($records, 'pre');
- //Print out all predecessor nodes
- print_r($all_pre);
- ?> ;
Copy code
|