I'm trying to push an array into a variable in php7. My code is:
public $services = array(
'01' => 'Canada Post - Priority',
'02' => 'Canada Post - Regular Parcel',
'03' => 'Canada Post - Xpresspost',
'04' => 'Purolator Express 9AM',
'05' => 'Purolator Express 1030AM',
'06' => 'Purolator Express',
'07' => 'Purolator Ground',
);
Instead of the harded code part I wish to push my array that I've obtain in this way
public function easypost_database()
{
\EasyPost\EasyPost::setApiKey('mykey');
$cas = \EasyPost\CarrierAccount::all();
$carriers = array();
foreach($cas as $key=>$value) {
$carriers[] = $value['type'];
}
return $carriers;
}
My array $carriers looks like that;
Array ( [0] => CanadaPostAccount
[1] => PurolatorAccount )
The problem is that when I associate my variable with my array my code breaks.
public $services = $carriers;
and
public $services = $this->easypost_database();
won't work.