json_decode and filenames

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jasonlfunk
Forum Newbie
Posts: 5
Joined: Sun Oct 18, 2009 7:22 pm

json_decode and filenames

Post by jasonlfunk »

Hello, I'm having trouble with the json_decode function. Here is some sample code:

Code: Select all

$test = '{"ZTDA5":[["Policy","C:\\files\\1\\Health.pdf"]]}';
$ret = json_decode($test);
var_dump($ret);
 
$ret is always NULL - even though the string I am passing it is valid JSON. Any ideas?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: json_decode and filenames

Post by requinix »

Actually, it's not valid. \\ is converted to \ even in single-quoted strings.

$test contains the value

Code: Select all

'{"ZTDA5":[["Policy","C:\files\1\Health.pdf"]]}'
\f, \1, and \H are not valid characters.
Post Reply