Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,051 questions

40,769 answers

573 users

How to decode a JSON string and check for error in PHP

1 Answer

0 votes
//                                          :  
$json_string = '{"name": "Tim", "profession" "Programmer", "language": ["PHP", "JAVA"]}';
$array = json_decode($json_string, true);
                      
echo "<pre>";
var_dump($array, json_last_error_msg());
echo "</pre>";

/*
run: 
 
NULL
string(12) "Syntax error"
 
*/

 





answered Sep 3, 2017 by avibootz

Related questions

5 answers 150 views
3 answers 106 views
2 answers 119 views
119 views asked Jul 2, 2016 by avibootz
...