简体   繁体   中英

How to extract first element of each array into array PHP

Sometimes when you are performing db queries, you might need only the first element of the arrays whereas PHP result array will give you an array of arrays containing one element each. What is the best way to extract each element into an array eg

Say you have array(array('silas'), array('douglas'))

but you need array('silas', 'douglas');

您可以使用array_map('array_shift', $your_array);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM