简体   繁体   中英

Retrieve values from json encoded string

I am storing a concatenated string like this:

echo json_encode($PostedDate.$Places.$Company.$Designation.$ProjectDetails.$DesiredCandidate.$HRName.$HRContact.$Email);

I can split this string using JavaScript and store values in an array. But what I want to know is that suppose any of the values above is null, will it affect the array position?

Because, I want to keep the array location fixed. For example:

myArray[0] must hold $PostedDate.

If $PostedDate is null, then also, myArray[0] must be equal to NULL. $Places must not take the position of myArray[0].

Put it into an array in php and then json_encode the array. Then you dont need to do your crazy split on the javascript side and you dont need to worry about preserving a position in a string.

put the strings onto a php array like so:

echo json_encode(array($PostedDate,$Places,$Company));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM