You have define $plan
with array so no need to take []
with $plans
because it create multi dimentional array.
I have added both example with and without []
.
Note
$plans[] = array(); // It creates multi dimensional array
$plans = array(); // It creates simple array
Code
<?php
$plans[] = array(
'provider' => 'Boost Mobile',
'plan' => 'Unlimited Gigs',
'url' => 'https://www.boostmobile.com/#!/shop/plans/monthly-phone-plans/',
'price' => 50,
'duration' => 'month');
print_r($plans);
echo $plans[0]['plan']; echo "
";
$plans2 = array(
'provider' => 'Boost Mobile',
'plan' => 'Unlimited Gigs',
'url' => 'https://www.boostmobile.com/#!/shop/plans/monthly-phone-plans/',
'price' => 50,
'duration' => 'month');
print_r($plans2);
echo $plans2['plan'];
Output
Array
(
[0] => Array
(
[provider] => Boost Mobile
[plan] => Unlimited Gigs
[url] => https://www.boostmobile.com/#!/shop/plans/monthly-phone-plans/
[price] => 50
[duration] => month
)
)
Unlimited Gigs
Array
(
[provider] => Boost Mobile
[plan] => Unlimited Gigs
[url] => https://www.boostmobile.com/#!/shop/plans/monthly-phone-plans/
[price] => 50
[duration] => month
)
Unlimited Gigs
Check Demo : Click Here