Get column of last names from a recordset in PHP
Description
The following code shows how to get column of last names from a recordset.
Example
//from ww w. ja va 2 s . c o m
<?php
// An array that represents a possible record set returned from a database
$a = array(
array(
'id' => 1,
'first_name' => 'XML',
'last_name' => 'HTML',
),
array(
'id' => 2,
'first_name' => 'HTML',
'last_name' => 'CSS',
),
array(
'id' => 3,
'first_name' => 'CSS',
'last_name' => 'Java',
)
);
$last_names = array_column($a, 'last_name');
print_r($last_names);
?>
The code above generates the following result.