skip to Main Content

I’m working on a php magento script which have a array variable for store some script urls.

array variable $items['js']

var_dump

array(1) {
[""]=>
array(17) {
["prototype/prototype.js"]=>
string(22) "prototype/prototype.js"
["varien/form.js"]=>
string(14) "varien/form.js"
["mage/translate.js"]=>
string(17) "mage/translate.js"
["mage/cookies.js"]=>
string(15) "mage/cookies.js"
["wyomind/layer/native.history.js"]=>
string(31) "wyomind/layer/native.history.js"
["varien/weee.js"]=>
string(14) "varien/weee.js"
["geissweb/vatvalidation-min.js"]=>
string(29) "geissweb/vatvalidation-min.js"
}
}

I tried to access the “geissweb/vatvalidation-min.js” value like this

$items['js']['geissweb/vatvalidation-min.js']

but it return empty value, is there have a way to get that value without use foreach or for loop. Thank You

2

Answers


  1. You have your variable $items['js'] as an array of arrays what your looking for without a foreach is this :

    $items['js'][0]['geissweb/vatvalidation-min.js'] is not valid
    

    after tests

     $items['js'][""]['geissweb/vatvalidation-min.js'] is valid.
    
    Login or Signup to reply.
  2. Your index is ”, shown by…

    array(1) {
    [""]=>
    

    so you need to use…

    $items['js']['']['geissweb/vatvalidation-min.js']
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search