Ahmed Ebraheem
Ahmed Ebraheem

Reputation: 63

Convert string like this to php array?

I want to convert a string like this code below to array, How can I do this plz?

$icon = '{``font``:``feather``,``icon``:``feather-facebook``}';

Is there any way by using json_decode or something like this?

Thanks.

Upvotes: 1

Views: 27

Answers (1)

Shubham Srivastava
Shubham Srivastava

Reputation: 1877

  1. The input string is not proper json format
  2. When you correct json syntax then you can just json_decode it
    $icon = '{"font":"feather","icon":"feather-facebook"}';
    $array = json_decode($icon);
    var_dump($array);

Upvotes: 1

Related Questions