I am having a multidimensional array, which I got from db results
$property['property'] = $this->property->property_filter($data);
Array looks like this
array(6) {
[0]=>
object(stdClass)#78 (20) {
["property_id"]=>
string(2) "27"
["user_id"]=>
string(1) "1"
["type_id"]=>
string(2) "13"
["contract_id"]=>
string(1) "1"
["city_id"]=>
string(1) "1"
["area_id"]=>
string(2) "15"
["date_added"]=>
string(10) "2015-04-29"
..............goes on...
I want to push a value manually in array. I tried like this
$property['property'][0]['image']="lankahomes_23_2.jpg";
I am not getting any errors. but it's not working.
Any suggestions or any better way to push values into multi-dimensional array in CodeIgniter?
Take a look at the dump.
$property['property']
is array
of objects
,
so $property['property'][0]
is object,
and its property should be reference by ->
not [ ]
.
So correct code is:
$property['property'][0]->image = "lankahomes_23_2.jpg";