php - Array push another array -
the following current array return database via eloquent of laravel. want push array , may know how to?
the data in return
company object ( [attributes] => array ( [id] => 1 [company_name] => superman [company_fullname] => superman ent. ) [original] => array ( [id] => 1 [company_name] => superman [company_fullname] => superman ent. ) [relationships] => array ( ) [exists] => 1 [includes] => array ( ) ) while can call via foreach array , access {{ $x->company_name }}. want extend array custom information like, total member count?
i tried in way , failed.
$temp = array("count" => "1232"); array_push($companyinfo, $temp); i got this
array_push() expects parameter 1 array, object given
update companyinfo array return laravel, , due foolish & careless (few days sleepless night +_+) didn't notice inside ['attributes']! data can access follow after applied methods answer.
{{ $x['attributes']['company_name'] }} {{ $x[0]['count'] }}
$companyinfo in case object. need either specify named parameter save $temp array info:
$temp = array("count" => "1232"); $companyinfo->temp = $temp; or cast object array:
$temp = array("count" => "1232"); $companyinfo = (array) $companyinfo; array_push($companyinfo, $temp);
Comments
Post a Comment