php - Merging multiple objects -


i have mysql query goes through framework (wolfcms).

$sql_query = 'select distinct country ' . $tablename . ' order country asc'; $countries = record::query($sql_query, array()); //execute query 

but returned array of objects this

array ( [0] => stdclass object (          [country] => canada ) [1] => stdclass object (          [country] => france ) ) 

i wondering if there way php merge object array simple possible like

array ( [0] => canada  [1]  => france ) 

i know parse array foreach loop once data , create custom array way needed wondering if there way directly data it's final form database.

i want simple array use parameter autocomplete function on text field.

* edit *

i found better way. had avoid executing query record class.

here's how

//create sql statement $sql_query = 'select distinct country' .              ' ' . record::tablenamefromclassname(__class__) .              ' order country asc'; $stmt = record::getconnection()->prepare($sql_query); $stmt->execute(array()); return $stmt->fetchall(record::fetch_column); 

have tried array_map?

$countries = array_map(function ($item) { return $item->country; }, $result ); 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -