Home > OS >  How can I get data from an array inside of string in php? json_decode() is not working
How can I get data from an array inside of string in php? json_decode() is not working

Time:02-07

I'm facing a problem with some points in my php program. Look here -

If I put variable inside of var_dump then it shows that data -

string(312) "[
                 {
                     "icon": "fab fa-facebook-f",
                     "link": "#",
                     "id": "customizer-repeater-social-repeater-61fa256703e54"
                 },
                 {
                     "icon": "fab fa-twitter",
                     "link": "#",
                     "id": "customizer-repeater-social-repeater-61fa28cd3dd31"
                 }
             ]"

And If I put variable inside of print_r then it shows that data -

[
    {
        "icon": "fab fa-facebook-f",
        "link": "#",
        "id": "customizer-repeater-social-repeater-61fa256703e54"
    },
    {
        "icon": "fab fa-twitter",
        "link": "#",
        "id": "customizer-repeater-social-repeater-61fa28cd3dd31"
    }
]"

How can I get icon and link from the object inside of this array????

Note: I've already tried with json_decode() method for converting string to array. But it gives me NULL

Can you help me to figure out what can I do to get the link and icon data in a loop?????

CodePudding user response:

If I put variable inside of print_r then it shows that data -

...

]"            
  •  Tags:  
  • Related