1: Output JSON first
Combination Doctor information Json$jsondoctorinfo = "{\" mecdoctor\ ": ["; $jsonDoctorInfo. = "{\" doctorid\ ": \" ". $doctorId." \ ", \" doctorname\ ": \" ". $strDoctorName." \ ", \" doctorprice\ ": \" ". $strPrice." \ ", \" expertise\ ": \" ". $strExpertise." \ ", \" departments\ ": \" ". $strdepartments." \ ", \" doctortitle\ ": \" ". $strTitle." \ ", \" doctorphoto\ ": \" ". $strDoctorPhoto." \ "}"; $jsonDoctorInfo. = "]}";
2: Get and Decode
$jsonGetDoctorInfoData = Json_encode ($jsonGetDoctorInfoData);
$objGetDoctorInfoData = Json_decode ($jsonGetDoctorInfoData);
Output:
{"Mecdoctor": [{"Doctorid": "", "Doctorname": "XXXX", "Doctorprice": "122", "expertise": "XXXXX", "Departments": "Medical Internal Medicine", " Doctortitle ": Chief Physician", "Doctorphoto": "HMH"}]}
3: Convert JSON to an array
Parse JSON data function _json_decode ($json) {$comment = false; $out = ' $x = '; for ($i =0; $i
4: There is a problem
Parse error:syntax error, unexpected T_double_arrow in/home/u945504094/public_html/config/config.inc.php (876): eval ( ) ' d Code on line 1
Reply to discussion (solution)
Please help me to see where the hell is wrong.
$s = ' {"Mecdoctor": [{"Doctorid": "", "Doctorname": "XXXX", "Doctorprice": "122", "expertise": "XXXXX", "Departments": " Medical internal Medicine "," Doctortitle ":" Chief Physician "," Doctorphoto ":" HMH "}]} ';p Rint_r (Json_decode ($s, true));
Array ([ mecdoctor] = = Array ( [0] = = Array ( [Doctorid] = [Doctorname] = XXXX [Doctorprice] = 122 [Expertise] = XXXXX [Departments] = Medical Department [Doctortitle] = chief physician [Doctorphoto] = HMH ) c12/>))
You didn't give the code near the wrong line, and naturally you don't know what's wrong with you.
Thank you Moderator,
After I get the JSON in the second step, I bring $s into function _json_decode ($json) {error occurred in
4: There is a problem
Parse error:syntax error, unexpected T_double_arrow in/home/u945504094/public_html/config/config.inc.php (876): eval ( ) ' d Code on line 1
$s = ' {"Mecdoctor": [{"Doctorid": "", "Doctorname": "XXXX", "Doctorprice": "122", "expertise": "XXXXX", "Departments": " Medical internal Medicine "," Doctortitle ":" Chief Physician "," Doctorphoto ":" HMH "}]} ';p Rint_r (Json_decode ($s, true));
Array ([ mecdoctor] = = Array ( [0] = = Array ( [Doctorid] = [Doctorname] = XXXX [Doctorprice] = 122 [Expertise] = XXXXX [Departments] = Medical Department [Doctortitle] = chief physician [Doctorphoto] = HMH ) c12/>))
You didn't give the code near the wrong line, and naturally you don't know what's wrong with you.
Also ask, why I get the JSON string through File_get_content, decode when the true parameter can not parse the array, but directly to the obtained JSON to a variable after the test can be transferred to the group?
$urlGetDoctorInfo = "http://127.0.0.1:8080/mobileInterface/mobileDataInterface.php?" Action=showdoctorinfo&doctorid= ". $_request[' Doctorid '); $jsonGetDoctorInfoData = file_get_contents ($ Urlgetdoctorinfo);p Rint_r (Json_decode ($jsonGetDoctorInfoData, True));//data is empty//the string is worn to the variable $s= ' {' mecdoctor ': [{' Doctorid ":" "," Doctorname ":" xxx "," Doctorprice ":" 122 "," expertise ":" XXX "," Departments ":" Internal Medicine "," Doctortitle ":" Chief Physician ", "Doctorphoto": "HMH"}]} ';p Rint_r (Json_decode ($s, true));//Normal output
May I ask why this is?
No problem.
$s = ' {"Mecdoctor": [{"Doctorid": "", "Doctorname": "XXXX", "Doctorprice": "122", "expertise": "XXXXX", "Departments": " Medical internal Medicine "," Doctortitle ":" Chief Physician "," Doctorphoto ":" HMH "}]} ';p Rint_r (_json_decode ($s)); function _json_decode ($json) {$comment = false; $out = ' $x = '; for ($i =0; $i
Array ([ mecdoctor] = = Array ( [0] = = Array ( [Doctorid] = [Doctorname] = XXXX [Doctorprice] = 122 [Expertise] = XXXXX [Departments] = Medical Department [Doctortitle] = chief physician [Doctorphoto] = HMH ) c12/>))
Yes, the moderator, but the file is not available.
Also ask, why I get the JSON string through File_get_content, decode when the true parameter can not parse the array, but directly to the obtained JSON to a variable after the test can be transferred to the group?
$urlGetDoctorInfo = "http://127.0.0.1:8080/mobileInterface/mobileDataInterface.php?" Action=showdoctorinfo&doctorid= ". $_request[' Doctorid '); $jsonGetDoctorInfoData = file_get_contents ($ Urlgetdoctorinfo);p Rint_r (Json_decode ($jsonGetDoctorInfoData, True));//data is empty//the string is worn to the variable $s= ' {' mecdoctor ': [{' Doctorid ":" "," Doctorname ":" xxx "," Doctorprice ":" 122 "," expertise ":" XXX "," Departments ":" Internal Medicine "," Doctortitle ":" Chief Physician ", "Doctorphoto": "HMH"}]} ';p Rint_r (Json_decode ($s, true));//Normal output
May I ask why this is?
$urlGetDoctorInfo = "http://127.0.0.1:8080/mobileInterface/mobileDataInterface.php?" Action=showdoctorinfo&doctorid= ". $_request[' Doctorid '); $jsonGetDoctorInfoData = file_get_contents ($ Urlgetdoctorinfo);p Rint_r (Json_decode ($jsonGetDoctorInfoData, True));//data is empty//the string is worn to the variable $s= ' {' mecdoctor ': [{' Doctorid ":" "," Doctorname ":" xxx "," Doctorprice ":" 122 "," expertise ":" XXX "," Departments ":" Internal Medicine "," Doctortitle ":" Chief Physician ", "Doctorphoto": "HMH"}]} ';p Rint_r (Json_decode ($s, true));//Normal output publishers, please see what the problem is, just the problem.
No problem.
$s = ' {"Mecdoctor": [{"Doctorid": "", "Doctorname": "XXXX", "Doctorprice": "122", "expertise": "XXXXX", "Departments": " Medical internal Medicine "," Doctortitle ":" Chief Physician "," Doctorphoto ":" HMH "}]} ';p Rint_r (_json_decode ($s)); function _json_decode ($json) {$comment = false; $out = ' $x = '; for ($i =0; $i
array ([mecdoctor] = = Array ([0] = = Array ([Doctorid] = [Doctorname] = XXXX [Doctorprice] = > 122 [Expertise] = XXXXX [Departments] = Medical Internal Medicine [Doctort Itle] = chief Physician [Doctorphoto] = HMH))
That's the coding problem!
Json_decode can only recognize UTF-8 encoded data