Issue with single quote in multiple line json data in php

Viewed 19
$arr = '{
    
    "38": {
        "email": "zhangshizhu08@163.com",
        "history": "Baldwin's,DNW"
    },
    "39": {
        "email": "john@filcombe.com",
        "history": "Spink"
    },
   
}';

$p_array = json_decode($dat,true);
print_r($p_array);
1 Answers

Try to use heredoc this way

$jsonString = <<<JSON 
{
    "38": {
        "email": "zhangshizhu08@163.com",
        "history": "Baldwin's,DNW"
    },
    "39": {
        "email": "john@filcombe.com",
        "history": "Spink"
    }
}
JSON;
$p_array = json_decode($jsonString, true); 
print_r($p_array);

Hope this helps.

Related