i have a array like below:
Array ( [0] => stdClass Object ( [city_name] => Hyderabad )
[1] => stdClass Object ( [city_name] => Visakhapatnam )
[and so on..] => and so on...
)
this array is return by this block of code:::
$query = "select city_name from city";
$result = $CI->Dbmodel->customQueryResult($query);
print_r(array_values($result));
and i would like to convert the above array to:
array('Hyderabad','Visakhapatnam','and so on..')
do php provide any built-in-function?
how can i do this?.. any help or suggestion would be a great help..thanks in advance
This should work:
$query = "select city_name from city";
$result = $CI->Dbmodel->customQueryResult($query)->result_array();
print_r($result);
If you can't modify your model use this code
$reslt = array();
foreach($result_array as $value){
$reslt[] = $value->city_name;
}
or use result_array()
function.