Let’s say I have a variable $data[‘media’];
The problem is the data might be either look like a string so for example
$data['media'] = '1|BlahBLah2|0'
or it might come in as json encoded string such as
$data['media'] = '{"site_id":"1","string":"BlahBlah2","cool":"0"}';
What is the best way to distinguish if it’s a delimited string or json encoded string?
json_decodewill return decoded data orNULLif it’s not json data, so you could use something like this: