我有一个像{"gclid":"Cj0KEQjw7dfKBRCdkKrvmfKtyeoBEiQAch0egQ97fbdyRpkv6sUmkYHXnTKlOWMywt3SceAol-1umzwaAmsk8P8HAQ","sem_keyword":"+turbolader +einbau","sem_creativeid":"165357442696","sem_matchtype":"b","sem_network":"g","sem_device":"m","sem_placement":"","sem_target":"","sem_adposition":"1t2","sem_param1":"","sem_param2":"","sem_campaignid":"629608072","sem_adgroupid":"38134265464","sem_targetid":"kwd-26982332150","sem_location":"1004645"}
我需要提取Cj0KEQjw7dfKBRCdkKrvmfKtyeoBEiQAch0egQ97fbdyRpkv6sUmkYHXnTKlOWMywt3SceAol-1umzwaAmsk8P8HAQ
,即gclid
后两个双引号之间的数据。
我已经尝试了所有子字符串函数,但我甚至无法接近。
答案 0 :(得分:0)
您可以使用MySQL JSON函数:
select json_unquote(json_extract(url, '$.gclid'))
答案 1 :(得分:0)
$json = file_get_contents('url_here');
$obj = json_decode($json);
echo $obj->gclid;
为此,file_get_contents
要求启用allow_url_fopen
。这可以在运行时通过包含ini_set("allow_url_fopen", 1);