0

To Clarify I used JSON.stringify(myArray) from view before I sent it to controller.

I have string array like following :

[
                [["\"1\"","\"1\""],["\"a\"","\"a\""]],
                [["\"2\"","\"2\""],["\"b\"","\"b\""],["\"c\"","\"c\""]],
                []
]

I want to fetch data by using foreach.

Like :

0- 1, 1 and a,a 
1- 2,2 and b,b and c,c 
2- null

I tried string_data[0][0] , it doesn't work.

And

foreach(string_data[0] as $value){
}

It also doesn't work.

Only string_data[0] works.

Insanity Geek
  • 157
  • 1
  • 12

1 Answers1

1

Solution is :

json_decode(VARIABLE, true)

Coz it(array) was sent from view as json.Stringfy. Php json decode function make it array again.

Insanity Geek
  • 157
  • 1
  • 12
  • Welcome to StackOverflow. Answers with only code in them tend to get flagged for deletion as they are "low quality". Please read the help section on answering questions then consider adding some commentary to your Answer. – Graham Mar 08 '18 at 06:55
  • Why is that the answer? What does it do? What is the meaning of the second parameter? – sorak Mar 08 '18 at 08:05
  • 1
    explanation given – Insanity Geek Mar 08 '18 at 08:21