-1

I have a multidimensional array and I want the first key that is dynamic. How do I get that in PHP?

I want to display the customer name in frontend. But as you can see in the first array there is the number [12345] => account number (the dynamic part). So if i want to display customer name how can I get this with this dynamic account number.

Array
   (
     [12345] => Array(
                    ['customername'] => ABC
                    ['customerid'] => 456
                   )
)
xbakesx
  • 13,202
  • 6
  • 48
  • 76
amit sutar
  • 541
  • 2
  • 11
  • 37
  • 3
    Does this answer your question? [Get first key in a (possibly) associative array?](https://stackoverflow.com/questions/1028668/get-first-key-in-a-possibly-associative-array) ... Next time, please take a moment to read the "Similar Questions" box that appears below the subject line when you type in a question. There are lots of answers to this on SO. – Markus AO Aug 04 '20 at 20:22
  • you can get into problems if the account number is an integer value. it is Ok while it is small, but when it gets to huge value the cript will fail with "out of memory" error even with 1 element in array. – Игорь Тыра Aug 04 '20 at 21:09

1 Answers1

0

Try with Foreach

foreach($array as $value){
   echo $value['customername'].'<br>';
   echo $value['customerid'].'<br>';
}
MD. Jubair Mizan
  • 1,539
  • 1
  • 12
  • 20