SOURAV SOURAV - 3 months ago 9
JSON Question

PHP json decoding of string array

I used this code for encoding:

$cont = json_encode(array_chunk($arr_content, 1, true));


My encoded data of var_dump($cont) is:

string(2670) "[[""],{"1":"Synonyms for good<\/b> at Thesaurus.com with free online thesaurus, antonyms, and \ndefinitions. Dictionary and Word of the Day."},{"2":"A magazine for the global citizen covering stories from business, environment, \npolitics, art, design, culture, technology, education, urban issues and the latest\u00a0..."},{"3":"It is good<\/b> that you are here. His credentials are good<\/b>. 5. well-behaved: a good<\/b> \nchild. 6. kind, beneficent, or friendly: to do a good<\/b> deed. 7. honorable or worthy; in\n\u00a0..."},{"4":"The secure mobility solution that unlocks your mobile potential."},{"5":"The latest Tweets from GOOD<\/b> (@good<\/b>). A magazine for the global citizen. Los \nAngeles, CA."},{"6":"of high quality. : of somewhat high but not excellent quality. : correct or proper. 48 \nwords to make in SCRABBLE with Q and no U \u00bb. bet\u00b7ter \\\u02c8be-t\u0259r\\ best \\\u02c8best\\\u00a0..."},{"7":"From Middle English good<\/b>, from Old English g\u014dd (\u201cgood<\/b>, virtuous, desirable, \nfavorable, salutary, pleasant, valid, efficient, suitable, considerable, sufficiently\u00a0..."},{"8":"Lets users track and rate books and network with other readers."},{"9":"GOOD<\/b>. 364873 likes \u00b7 19190 talking about this. GOOD<\/b> is a place to share \ncreative solutions for living well and doing good<\/b>."},{"10":"The rise of national socialism in Germany should not be regarded as a \nconspiracy of madmen. Millions of "good<\/b>" people found themselves in a society \nspiralling\u00a0..."},{"11":"We are GOOD's<\/b> social innovation consultancy. We work with organizations to \nimagine bold leadership opportunities that align metrics with social impact."},{"12":"Good<\/b> may refer to: ... This disambiguation page lists articles associated with the \ntitle Good<\/b>. If an internal link led you here, you may wish to change the link to\u00a0..."},{"13":"Good<\/b> articles are considered to be of good<\/b> quality, but are not yet as qualified as \nfeatured articles. Good<\/b> articles meet the good<\/b> article criteria, passing through\u00a0..."},{"14":"We are Rhett & Link and this is our daily morning talk show, Good<\/b> Mythical \nMorning. Check out our main channel for funny music videos, sketches, and \nridiculo..."},{"15":"Log in to your Network for Good<\/b> account to access donation history, product \nconfiguration, and more."},{"16":"Good<\/b> Sam Club \u2013 RV Club camping memberships, services, RV Park and \ncampground discounts, online travel resources, members only Camping World \noffers,\u00a0..."}]" string(2670) "[[""],{"1":"Synonyms for good<\/b> at Thesaurus.com with free online thesaurus, antonyms, and \ndefinitions. Dictionary and Word of the Day."},{"2":"A magazine for the global citizen covering stories from business, environment, \npolitics, art, design, culture, technology, education, urban issues and the latest\u00a0..."},{"3":"It is good<\/b> that you are here. His credentials are good<\/b>. 5. well-behaved: a good<\/b> \nchild. 6. kind, beneficent, or friendly: to do a good<\/b> deed. 7. honorable or worthy; in\n\u00a0..."},{"4":"The secure mobility solution that unlocks your mobile potential."},{"5":"The latest Tweets from GOOD<\/b> (@good<\/b>). A magazine for the global citizen. Los \nAngeles, CA."},{"6":"of high quality. : of somewhat high but not excellent quality. : correct or proper. 48 \nwords to make in SCRABBLE with Q and no U \u00bb. bet\u00b7ter \\\u02c8be-t\u0259r\\ best \\\u02c8best\\\u00a0..."},{"7":"From Middle English good<\/b>, from Old English g\u014dd (\u201cgood<\/b>, virtuous, desirable, \nfavorable, salutary, pleasant, valid, efficient, suitable, considerable, sufficiently\u00a0..."},{"8":"Lets users track and rate books and network with other readers."},{"9":"GOOD<\/b>. 364873 likes \u00b7 19190 talking about this. GOOD<\/b> is a place to share \ncreative solutions for living well and doing good<\/b>."},{"10":"The rise of national socialism in Germany should not be regarded as a \nconspiracy of madmen. Millions of "good<\/b>" people found themselves in a society \nspiralling\u00a0..."},{"11":"We are GOOD's<\/b> social innovation consultancy. We work with organizations to \nimagine bold leadership opportunities that align metrics with social impact."},{"12":"Good<\/b> may refer to: ... This disambiguation page lists articles associated with the \ntitle Good<\/b>. If an internal link led you here, you may wish to change the link to\u00a0..."},{"13":"Good<\/b> articles are considered to be of good<\/b> quality, but are not yet as qualified as \nfeatured articles. Good<\/b> articles meet the good<\/b> article criteria, passing through\u00a0..."},{"14":"We are Rhett & Link and this is our daily morning talk show, Good<\/b> Mythical \nMorning. Check out our main channel for funny music videos, sketches, and \nridiculo..."},{"15":"Log in to your Network for Good<\/b> account to access donation history, product \nconfiguration, and more."},{"16":"Good<\/b> Sam Club \u2013 RV Club camping memberships, services, RV Park and \ncampground discounts, online travel resources, members only Camping World \noffers,\u00a0..."}]" string(2670) "[[""],{"1":"Synonyms for good<\/b> at Thesaurus.com with free online thesaurus, antonyms, and \ndefinitions. Dictionary and Word of the Day."},{"2":"A magazine for the global citizen covering stories from business, environment, \npolitics, art, design, culture, technology, education, urban issues and the latest\u00a0..."},{"3":"It is good<\/b> that you are here. His credentials are good<\/b>. 5. well-behaved: a good<\/b> \nchild. 6. kind, beneficent, or friendly: to do a good<\/b> deed. 7. honorable or worthy; in\n\u00a0..."},{"4":"The secure mobility solution that unlocks your mobile potential."},{"5":"The latest Tweets from GOOD<\/b> (@good<\/b>). A magazine for the global citizen. Los \nAngeles, CA."},{"6":"of high quality. : of somewhat high but not excellent quality. : correct or proper. 48 \nwords to make in SCRABBLE with Q and no U \u00bb. bet\u00b7ter \\\u02c8be-t\u0259r\\ best \\\u02c8best\\\u00a0..."},{"7":"From Middle English good<\/b>, from Old English g\u014dd (\u201cgood<\/b>, virtuous, desirable, \nfavorable, salutary, pleasant, valid, efficient, suitable, considerable, sufficiently\u00a0..."},{"8":"Lets users track and rate books and network with other readers."},{"9":"GOOD<\/b>. 364873 likes \u00b7 19190 talking about this. GOOD<\/b> is a place to share \ncreative solutions for living well and doing good<\/b>."},{"10":"The rise of national socialism in Germany should not be regarded as a \nconspiracy of madmen. Millions of "good<\/b>" people found themselves in a society \nspiralling\u00a0..."},{"11":"We are GOOD's<\/b> social innovation consultancy. We work with organizations to \nimagine bold leadership opportunities that align metrics with social impact."},{"12":"Good<\/b> may refer to: ... This disambiguation page lists articles associated with the \ntitle Good<\/b>. If an internal link led you here, you may wish to change the link to\u00a0..."},{"13":"Good<\/b> articles are considered to be of good<\/b> quality, but are not yet as qualified as \nfeatured articles. Good<\/b> articles meet the good<\/b> article criteria, passing through\u00a0..."},{"14":"We are Rhett & Link and this is our daily morning talk show, Good<\/b> Mythical \nMorning. Check out our main channel for funny music videos, sketches, and \nridiculo..."},{"15":"Log in to your Network for Good<\/b> account to access donation history, product \nconfiguration, and more."},{"16":"Good<\/b> Sam Club \u2013 RV Club camping memberships, services, RV Park and \ncampground discounts, online travel resources, members only Camping World \noffers,\u00a0..."}]" string(2670) "[[""],{"1":"Synonyms for good<\/b> at Thesaurus.com with free online thesaurus, antonyms, and \ndefinitions. Dictionary and Word of the Day."},{"2":"A magazine for the global citizen covering stories from business, environment, \npolitics, art, design, culture, technology, education, urban issues and the latest\u00a0..."},{"3":"It is good<\/b> that you are here. His credentials are good<\/b>. 5. well-behaved: a good<\/b> \nchild. 6. kind, beneficent, or friendly: to do a good<\/b> deed. 7. honorable or worthy; in\n\u00a0..."},{"4":"The secure mobility solution that unlocks your mobile potential."},{"5":"The latest Tweets from GOOD<\/b> (@good<\/b>). A magazine for the global citizen. Los \nAngeles, CA."},{"6":"of high quality. : of somewhat high but not excellent quality. : correct or proper. 48 \nwords to make in SCRABBLE with Q and no U \u00bb. bet\u00b7ter \\\u02c8be-t\u0259r\\ best \\\u02c8best\\\u00a0..."},{"7":"From Middle English good<\/b>, from Old English g\u014dd (\u201cgood<\/b>, virtuous, desirable, \nfavorable, salutary, pleasant, valid, efficient, suitable, considerable, sufficiently\u00a0..."},{"8":"Lets users track and rate books and network with other readers."},{"9":"GOOD<\/b>. 364873 likes \u00b7 19190 talking about this. GOOD<\/b> is a place to share \ncreative solutions for living well and doing good<\/b>."},{"10":"The rise of national socialism in Germany should not be regarded as a \nconspiracy of madmen. Millions of "good<\/b>" people found themselves in a society \nspiralling\u00a0..."},{"11":"We are GOOD's<\/b> social innovation consultancy. We work with organizations to \nimagine bold leadership opportunities that align metrics with social impact."},{"12":"Good<\/b> may refer to: ... This disambiguation page lists articles associated with the \ntitle Good<\/b>. If an internal link led you here, you may wish to change the link to\u00a0..."},{"13":"Good<\/b> articles are considered to be of good<\/b> quality, but are not yet as qualified as \nfeatured articles. Good<\/b> articles meet the good<\/b> article criteria, passing through\u00a0..."},{"14":"We are Rhett & Link and this is our daily morning talk show, Good<\/b> Mythical \nMorning. Check out our main channel for funny music videos, sketches, and \nridiculo..."},{"15":"Log in to your Network for Good<\/b> account to access donation history, product \nconfiguration, and more."},{"16":"Good<\/b> Sam Club \u2013 RV Club camping memberships, services, RV Park and \ncampground discounts, online travel resources, members only Camping World \noffers,\u00a0..."}]" string(2670) "[[""],{"1":"Synonyms for good<\/b> at Thesaurus.com with free online thesaurus, antonyms, and \ndefinitions. Dictionary and Word of the Day."},{"2":"A magazine for the global citizen covering stories from business, environment, \npolitics, art, design, culture, technology, education, urban issues and the latest\u00a0..."},{"3":"It is good<\/b> that you are here. His credentials are good<\/b>. 5. well-behaved: a good<\/b> \nchild. 6. kind, beneficent, or friendly: to do a good<\/b> deed. 7. honorable or worthy; in\n\u00a0..."},{"4":"The secure mobility solution that unlocks your mobile potential."},{"5":"The latest Tweets from GOOD<\/b> (@good<\/b>). A magazine for the global citizen. Los \nAngeles, CA."},{"6":"of high quality. : of somewhat high but not excellent quality. : correct or proper. 48 \nwords to make in SCRABBLE with Q and no U \u00bb. bet\u00b7ter \\\u02c8be-t\u0259r\\ best \\\u02c8best\\\u00a0..."},{"7":"From Middle English good<\/b>, from Old English g\u014dd (\u201cgood<\/b>, virtuous, desirable, \nfavorable, salutary, pleasant, valid, efficient, suitable, considerable, sufficiently\u00a0..."},{"8":"Lets users track and rate books and network with other readers."},{"9":"GOOD<\/b>. 364873 likes \u00b7 19190 talking about this. GOOD<\/b> is a place to share \ncreative solutions for living well and doing good<\/b>."},{"10":"The rise of national socialism in Germany should not be regarded as a \nconspiracy of madmen. Millions of "good<\/b>" people found themselves in a society \nspiralling\u00a0..."},{"11":"We are GOOD's<\/b> social innovation consultancy. We work with organizations to \nimagine bold leadership opportunities that align metrics with social impact."},{"12":"Good<\/b> may refer to: ... This disambiguation page lists articles associated with the \ntitle Good<\/b>. If an internal link led you here, you may wish to change the link to\u00a0..."},{"13":"Good<\/b> articles are considered to be of good<\/b> quality, but are not yet as qualified as \nfeatured articles. Good<\/b> articles meet the good<\/b> article criteria, passing through\u00a0..."},{"14":"We are Rhett & Link and this is our daily morning talk show, Good<\/b> Mythical \nMorning. Check out our main channel for funny music videos, sketches, and \nridiculo..."},{"15":"Log in to your Network for Good<\/b> account to access donation history, product \nconfiguration, and more."},{"16":"Good<\/b> Sam Club \u2013 RV Club camping memberships, services, RV Park and \ncampground discounts, online travel resources, members only Camping World \noffers,\u00a0..."}]" string(2670) "[[""],{"1":"Synonyms for good<\/b> at Thesaurus.com with free online thesaurus, antonyms, and \ndefinitions. Dictionary and Word of the Day."},{"2":"A magazine for the global citizen covering stories from business, environment, \npolitics, art, design, culture, technology, education, urban issues and the latest\u00a0..."},{"3":"It is good<\/b> that you are here. His credentials are good<\/b>. 5. well-behaved: a good<\/b> \nchild. 6. kind, beneficent, or friendly: to do a good<\/b> deed. 7. honorable or worthy; in\n\u00a0..."},{"4":"The secure mobility solution that unlocks your mobile potential."},{"5":"The latest Tweets from GOOD<\/b> (@good<\/b>). A magazine for the global citizen. Los \nAngeles, CA."},{"6":"of high quality. : of somewhat high but not excellent quality. : correct or proper. 48 \nwords to make in SCRABBLE with Q and no U \u00bb. bet\u00b7ter \\\u02c8be-t\u0259r\\ best \\\u02c8best\\\u00a0..."},{"7":"From Middle English good<\/b>, from Old English g\u014dd (\u201cgood<\/b>, virtuous, desirable, \nfavorable, salutary, pleasant, valid, efficient, suitable, considerable, sufficiently\u00a0..."},{"8":"Lets users track and rate books and network with other readers."},{"9":"GOOD<\/b>. 364873 likes \u00b7 19190 talking about this. GOOD<\/b> is a place to share \ncreative solutions for living well and doing good<\/b>."},{"10":"The rise of national socialism in Germany should not be regarded as a \nconspiracy of madmen. Millions of "good<\/b>" people found themselves in a society \nspiralling\u00a0..."},{"11":"We are GOOD's<\/b> social innovation consultancy. We work with organizations to \nimagine bold leadership opportunities that align metrics with social impact."},{"12":"Good<\/b> may refer to: ... This disambiguation page lists articles associated with the \ntitle Good<\/b>. If an internal link led you here, you may wish to change the link to\u00a0..."},{"13":"Good<\/b> articles are considered to be of good<\/b> quality, but are not yet as qualified as \nfeatured articles. Good<\/b> articles meet the good<\/b> article criteria, passing through\u00a0..."},{"14":"We are Rhett & Link and this is our daily morning talk show, Good<\/b> Mythical \nMorning. Check out our main channel for funny music videos, sketches, and \nridiculo..."},{"15":"Log in to your Network for Good<\/b> account to access donation history, product \nconfiguration, and more."},{"16":"Good<\/b> Sam Club \u2013 RV Club camping memberships, services, RV Park and \ncampground discounts, online travel resources, members only Camping World \noffers,\u00a0..."}]" string(2670) "[[""],{"1":"Synonyms for good<\/b> at Thesaurus.com with free online thesaurus, antonyms, and \ndefinitions. Dictionary and Word of the Day."},{"2":"A magazine for the global citizen covering stories from business, environment, \npolitics, art, design, culture, technology, education, urban issues and the......


And send that data through url using this code to another page:

header("Location: search.php?content=".$cont);


My Url is:

http://localhost/Nayve/search.php?content=[[%22nothing%22],{%221%22:%22Synonyms%20for%20%3Cb%3Egood%3C\/b%3E%20at%20Thesaurus.com%20with%20free%20online%20thesaurus,%20antonyms,%20and%20\ndefinitions.%20Dictionary%20and%20Word%20of%20the%20Day.%22},{%222%22:%22A%20magazine%20for%20the%20global%20citizen%20covering%20stories%20from%20business,%20environment,%20\npolitics,%20art,%20design,%20culture,%20technology,%20education,%20urban%20issues%20and%20the%20latest\u00a0...%22},{%223%22:%22It%20is%20%3Cb%3Egood%3C\/b%3E%20that%20you%20are%20here.%20His%20credentials%20are%20%3Cb%3Egood%3C\/b%3E.%205.%20well-behaved:%20a%20%3Cb%3Egood%3C\/b%3E%20\nchild.%206.%20kind,%20beneficent,%20or%20friendly:%20to%20do%20a%20%3Cb%3Egood%3C\/b%3E%20deed.%207.%20honorable%20or%20worthy;%20in\n\u00a0...%22},{%224%22:%22The%20secure%20mobility%20solution%20that%20unlocks%20your%20mobile%20potential.%22},{%225%22:%22The%20latest%20Tweets%20from%20%3Cb%3EGOOD%3C\/b%3E%20(@%3Cb%3Egood%3C\/b%3E).%20A%20magazine%20for%20the%20global%20citizen.%20Los%20\nAngeles,%20CA.%22},{%226%22:%22of%20high%20quality.%20:%20of%20somewhat%20high%20but%20not%20excellent%20quality.%20:%20correct%20or%20proper.%2048%20\nwords%20to%20make%20in%20SCRABBLE%20with%20Q%20and%20no%20U%20\u00bb.%20bet\u00b7ter%20\\\u02c8be-t\u0259r\\%20best%20\\\u02c8best\\\u00a0...%22},{%227%22:%22From%20Middle%20English%20%3Cb%3Egood%3C\/b%3E,%20from%20Old%20English%20g\u014dd%20%20%20(\u201c%3Cb%3Egood%3C\/b%3E,%20virtuous,%20desirable,%20\nfavorable,%20salutary,%20pleasant,%20valid,%20efficient,%20suitable,%20considerable,%20sufficiently\u00a0...%22},{%228%22:%22%3Cb%3EGOOD%3C\/b%3E.%20364873%20likes%20\u00b7%2019190%20talking%20about%20this.%20%3Cb%3EGOOD%3C\/b%3E%20is%20a%20place%20to%20share%20\ncreative%20solutions%20for%20living%20well%20and%20doing%20%3Cb%3Egood%3C\/b%3E.%22},{%229%22:%22Lets%20users%20track%20and%20rate%20books%20and%20network%20with%20other%20readers.%22},{%2210%22:%22The%20rise%20of%20national%20socialism%20in%20Germany%20should%20not%20be%20regarded%20as%20a%20\nconspiracy%20of%20madmen.%20Millions%20of%20&quot;%3Cb%3Egood%3C\/b%3E&quot;%20people%20found%20themselves%20in%20a%20society%20\nspiralling\u00a0...%22},{%2211%22:%22We%20are%20%3Cb%3EGOOD&#39;s<\/b> social innovation consultancy. We work with organizations to \nimagine bold leadership opportunities that align metrics with social impact."},{"12":"<b>Good<\/b> may refer to: ... This disambiguation page lists articles associated with the \ntitle <b>Good<\/b>. If an internal link led you here, you may wish to change the link to\u00a0..."},{"13":"<b>Good<\/b> articles are considered to be of <b>good<\/b> quality, but are not yet as qualified as \nfeatured articles. <b>Good<\/b> articles meet the <b>good<\/b> article criteria, passing through\u00a0..."},{"14":"We are Rhett &amp; Link and this is our daily morning talk show, <b>Good<\/b> Mythical \nMorning. Check out our main channel for funny music videos, sketches, and \nridiculo..."},{"15":"Log in to your Network for <b>Good<\/b> account to access donation history, product \nconfiguration, and more."},{"16":"<b>Good<\/b> Sam Club \u2013 RV Club camping memberships, services, RV Park and \ncampground discounts, online travel resources, members only Camping World \noffers,\u00a0..."}]


for receiving those data I used:

<?php
if ($_GET['content']!=null ) {
$array5=$_GET['content'];
$contents=json_decode($array5);
var_dump($contents);

}?>


Now when I decode it it's shows
Null


But If I Use
var_dump($array5);
then it don't show the full result.It shows:

string(1509) "[["nothing"],{"1":"Synonyms for good<\/b> at Thesaurus.com with free online thesaurus, antonyms, and \ndefinitions. Dictionary and Word of the Day."},{"2":"A magazine for the global citizen covering stories from business, environment, \npolitics, art, design, culture, technology, education, urban issues and the latest\u00a0..."},{"3":"It is good<\/b> that you are here. His credentials are good<\/b>. 5. well-behaved: a good<\/b> \nchild. 6. kind, beneficent, or friendly: to do a good<\/b> deed. 7. honorable or worthy; in\n\u00a0..."},{"4":"The secure mobility solution that unlocks your mobile potential."},{"5":"The latest Tweets from GOOD<\/b> (@good<\/b>). A magazine for the global citizen. Los \nAngeles, CA."},{"6":"of high quality. : of somewhat high but not excellent quality. : correct or proper. 48 \nwords to make in SCRABBLE with Q and no U \u00bb. bet\u00b7ter \\\u02c8be-t\u0259r\\ best \\\u02c8best\\\u00a0..."},{"7":"From Middle English good<\/b>, from Old English g\u014dd (\u201cgood<\/b>, virtuous, desirable, \nfavorable, salutary, pleasant, valid, efficient, suitable, considerable, sufficiently\u00a0..."},{"8":"GOOD<\/b>. 364873 likes \u00b7 19190 talking about this. GOOD<\/b> is a place to share \ncreative solutions for living well and doing good<\/b>."},{"9":"Lets users track and rate books and network with other readers."},{"10":"The rise of national socialism in Germany should not be regarded as a \nconspiracy of madmen. Millions of "

Answer

Using urlencode() when genrating the content and then urldecode when receiving the content may help I guess.

$cont = urlencode(json_encode(array_chunk($arr_content, 1, true)));

<?php 
if ($_GET['content']!=null ) {
  $array5=urldecode($_GET['content']);
  $contents=json_decode($array5);
  var_dump($contents);

}?>
Comments