Toggle navigation
Home
Latest pastes
FAQ
Random
Register
Login
Get column of last names from a recordset:
SUBMITTED BY:
henry1874w
DATE:
June 22, 2017, 12:09 a.m.
FORMAT:
Text only
SIZE:
526 Bytes
Raw
Download
Tweet
HITS:
328
Go to comments
Report
<?php
// An array that represents a possible record set
returned from a database
$a = array(
array(
'id' => 5698,
'first_name' => 'Peter',
'last_name' => 'Griffin',
),
array(
'id' => 4767,
'first_name' => 'Ben',
'last_name' => 'Smith',
),
array(
'id' => 3809,
'first_name' => 'Joe',
'last_name' => 'Doe',
)
);
$last_names = array_column($a, 'last_name');
print_r($last_names);
?>
Output:
Array
(
[0] => Griffin
[1] => Smith
[2] => Doe
)
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus