If you have PHP 5.5 or later, the best way is to use the built in function array_column()
:
$idCats = array_column($cats, 'id');
But the son has to be an array or converted to an array
More Related Contents:
- Fatal error: Switch statements may only contain one default clause (php7)
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘WHERE `id` [closed]
- PHP parse/syntax errors; and how to solve them
- PHP validation/regex for URL
- continue processing php after sending http response
- Parse XML with Namespace using SimpleXML [duplicate]
- Find a matching or closest value in an array
- PHP: Merge 2 Multidimensional Arrays
- “[notice] child pid XXXX exit signal Segmentation fault (11)” in apache error.log [closed]
- Why is using a mysql prepared statement more secure than using the common escape functions?
- Merging two json in PHP
- Extract JSONP Resultset in PHP
- How to change maximum number of POST variable in PHP?
- How can I know which ‘php.ini’ file is used?
- Convert PDF to JPEG with PHP and ImageMagick
- Shorthand for arrays: is there a literal syntax like {} or []?
- PHP function with variable as default value for a parameter
- Interactive shell using PHP
- Warning: array_combine(): Both parameters should have an equal number of elements
- What are the proper permissions for an upload folder with PHP/Apache?
- PDO MySQL: Insert multiple rows in one query
- Difference between file, file_get_contents, and fopen in PHP
- Dynamic Table Generation
- How to force Doctrine to update array type fields?
- Is there a limit when using php mail function?
- create superglobal variables in php?
- How to validate phone number using PHP? [duplicate]
- UTF-8 in PHP regular expressions [duplicate]
- Number in the top-level domain?
- finding common prefix of array of strings