Home > other >  how to remove index in php response
how to remove index in php response

Time:02-05

I've a variable $response which is an array and contains the below response

"example": {
     "1": {
         "name": "stan",
         "city": "NY"
      },
     "2": {
         "name": "wilson",
         "city": "FL"
      }
 }

How can I remove the indexing from the response?

CodePudding user response:

This may help:

array_values($response);

This resets all the keys/indexes of the array.

CodePudding user response:

Try this one :

array_values($response)
  •  Tags:  
  • Related