Home > Enterprise >  getting int value of array and saving it in another variable
getting int value of array and saving it in another variable

Time:08-21

i am new to php so sorry if this question is dumb

Thats the array I have

array(1) { [0]=> array(1) { ["count"]=> int(4) } }

and i just need to save the 4 in a new variable named 'number'

CodePudding user response:

The first subscript [0] gets you the first element of the array, the ['count'] gets you the 4 from within the first element.

$count = $arr[0]['count'];

CodePudding user response:

Its quite simple

$number = $array[0]["count"]

or do you want to loop through and find all integers in case of a larger array?

  •  Tags:  
  • php
  • Related