PHP Array_column() Function Example
Hello Friends,
Now let's see example of PHP Array_column() Function. We will talk about array_column() function in php.array_column() returns the values from a single column of the array , identified by the column_key . Optionally, an index_key may be provided to index the values in the returned array by the values from the index_key column of the input array. The array_column() function returns the values from a single column in the input array.
Here i will give you many example how you can check array_column() function in php file.
Syntax
array_column(array, column_key, index_key)
Example
<!DOCTYPE html>
<html>
<head>
<title>Php - How to check array_column() function in php - NiceSnippets.com?</title>
</head>
<body>
<?php
$a = array(
array(
'id' => 5698,
'first_name' => 'Chocolate',
'last_name' => 'kitkat',
),
array(
'id' => 4767,
'first_name' => 'Bike',
'last_name' => 'Activa',
),
array(
'id' => 3809,
'first_name' => 'Mobile',
'last_name' => 'Oppo',
)
);
$last_names = array_column($a, 'last_name');
print_r($last_names);
?>
</body>
</html>
Output:
Array ( [0] => kitkat [1] => Activa [2] => Oppo )
It will help you....
- How To Use Php Conditional Statement Example
- How to Check if String Contains Regex in PHP?
- PHP Generate List of Random Numbers Between 0 and 100 Example
- How to User Login with Facebook in PHP?
- How to Explode Every Character into Array Using PHP Example?
- PHP Form Validation Tutorial
- PHP Convert XML to JSON Example
- How To Add Year To Current Date In Php?