dongquming3255 2015-11-05 01:25
浏览 55
已采纳

PHP json解码字符串数组

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 
definitions. Dictionary and Word of the Day."},{"2":"A magazine for the global citizen covering stories from business, environment, 
politics, 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> 
child. 6. kind, beneficent, or friendly: to do a good<\/b> deed. 7. honorable or worthy; in
\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 
Angeles, CA."},{"6":"of high quality. : of somewhat high but not excellent quality. : correct or proper. 48 
words 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, 
favorable, 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 
creative solutions for living well and doing good<\/b>."},{"10":"The rise of national socialism in Germany should not be regarded as a 
conspiracy of madmen. Millions of "good<\/b>" people found themselves in a society 
spiralling\u00a0..."},{"11":"We are GOOD's<\/b> social innovation consultancy. We work with organizations to 
imagine bold leadership opportunities that align metrics with social impact."},{"12":"Good<\/b> may refer to: ... This disambiguation page lists articles associated with the 
title 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 
featured 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 
Morning. Check out our main channel for funny music videos, sketches, and 
ridiculo..."},{"15":"Log in to your Network for Good<\/b> account to access donation history, product 
configuration, and more."},{"16":"Good<\/b> Sam Club \u2013 RV Club camping memberships, services, RV Park and 
campground discounts, online travel resources, members only Camping World 
offers,\u00a0..."}]" string(2670) "[[""],{"1":"Synonyms for good<\/b> at Thesaurus.com with free online thesaurus, antonyms, and 
definitions. Dictionary and Word of the Day."},{"2":"A magazine for the global citizen covering stories from business, environment, 
politics, 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> 
child. 6. kind, beneficent, or friendly: to do a good<\/b> deed. 7. honorable or worthy; in
\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 
Angeles, CA."},{"6":"of high quality. : of somewhat high but not excellent quality. : correct or proper. 48 
words 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, 
favorable, 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 
creative solutions for living well and doing good<\/b>."},{"10":"The rise of national socialism in Germany should not be regarded as a 
conspiracy of madmen. Millions of "good<\/b>" people found themselves in a society 
spiralling\u00a0..."},{"11":"We are GOOD's<\/b> social innovation consultancy. We work with organizations to 
imagine bold leadership opportunities that align metrics with social impact."},{"12":"Good<\/b> may refer to: ... This disambiguation page lists articles associated with the 
title 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 
featured 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 
Morning. Check out our main channel for funny music videos, sketches, and 
ridiculo..."},{"15":"Log in to your Network for Good<\/b> account to access donation history, product 
configuration, and more."},{"16":"Good<\/b> Sam Club \u2013 RV Club camping memberships, services, RV Park and 
campground discounts, online travel resources, members only Camping World 
offers,\u00a0..."}]" string(2670) "[[""],{"1":"Synonyms for good<\/b> at Thesaurus.com with free online thesaurus, antonyms, and 
definitions. Dictionary and Word of the Day."},{"2":"A magazine for the global citizen covering stories from business, environment, 
politics, 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> 
child. 6. kind, beneficent, or friendly: to do a good<\/b> deed. 7. honorable or worthy; in
\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 
Angeles, CA."},{"6":"of high quality. : of somewhat high but not excellent quality. : correct or proper. 48 
words 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, 
favorable, 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 
creative solutions for living well and doing good<\/b>."},{"10":"The rise of national socialism in Germany should not be regarded as a 
conspiracy of madmen. Millions of "good<\/b>" people found themselves in a society 
spiralling\u00a0..."},{"11":"We are GOOD's<\/b> social innovation consultancy. We work with organizations to 
imagine bold leadership opportunities that align metrics with social impact."},{"12":"Good<\/b> may refer to: ... This disambiguation page lists articles associated with the 
title 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 
featured 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 
Morning. Check out our main channel for funny music videos, sketches, and 
ridiculo..."},{"15":"Log in to your Network for Good<\/b> account to access donation history, product 
configuration, and more."},{"16":"Good<\/b> Sam Club \u2013 RV Club camping memberships, services, RV Park and 
campground discounts, online travel resources, members only Camping World 
offers,\u00a0..."}]" string(2670) "[[""],{"1":"Synonyms for good<\/b> at Thesaurus.com with free online thesaurus, antonyms, and 
definitions. Dictionary and Word of the Day."},{"2":"A magazine for the global citizen covering stories from business, environment, 
politics, 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> 
child. 6. kind, beneficent, or friendly: to do a good<\/b> deed. 7. honorable or worthy; in
\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 
Angeles, CA."},{"6":"of high quality. : of somewhat high but not excellent quality. : correct or proper. 48 
words 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, 
favorable, 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 
creative solutions for living well and doing good<\/b>."},{"10":"The rise of national socialism in Germany should not be regarded as a 
conspiracy of madmen. Millions of "good<\/b>" people found themselves in a society 
spiralling\u00a0..."},{"11":"We are GOOD's<\/b> social innovation consultancy. We work with organizations to 
imagine bold leadership opportunities that align metrics with social impact."},{"12":"Good<\/b> may refer to: ... This disambiguation page lists articles associated with the 
title 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 
featured 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 
Morning. Check out our main channel for funny music videos, sketches, and 
ridiculo..."},{"15":"Log in to your Network for Good<\/b> account to access donation history, product 
configuration, and more."},{"16":"Good<\/b> Sam Club \u2013 RV Club camping memberships, services, RV Park and 
campground discounts, online travel resources, members only Camping World 
offers,\u00a0..."}]" string(2670) "[[""],{"1":"Synonyms for good<\/b> at Thesaurus.com with free online thesaurus, antonyms, and 
definitions. Dictionary and Word of the Day."},{"2":"A magazine for the global citizen covering stories from business, environment, 
politics, 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> 
child. 6. kind, beneficent, or friendly: to do a good<\/b> deed. 7. honorable or worthy; in
\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 
Angeles, CA."},{"6":"of high quality. : of somewhat high but not excellent quality. : correct or proper. 48 
words 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, 
favorable, 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 
creative solutions for living well and doing good<\/b>."},{"10":"The rise of national socialism in Germany should not be regarded as a 
conspiracy of madmen. Millions of "good<\/b>" people found themselves in a society 
spiralling\u00a0..."},{"11":"We are GOOD's<\/b> social innovation consultancy. We work with organizations to 
imagine bold leadership opportunities that align metrics with social impact."},{"12":"Good<\/b> may refer to: ... This disambiguation page lists articles associated with the 
title 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 
featured 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 
Morning. Check out our main channel for funny music videos, sketches, and 
ridiculo..."},{"15":"Log in to your Network for Good<\/b> account to access donation history, product 
configuration, and more."},{"16":"Good<\/b> Sam Club \u2013 RV Club camping memberships, services, RV Park and 
campground discounts, online travel resources, members only Camping World 
offers,\u00a0..."}]" string(2670) "[[""],{"1":"Synonyms for good<\/b> at Thesaurus.com with free online thesaurus, antonyms, and 
definitions. Dictionary and Word of the Day."},{"2":"A magazine for the global citizen covering stories from business, environment, 
politics, 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> 
child. 6. kind, beneficent, or friendly: to do a good<\/b> deed. 7. honorable or worthy; in
\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 
Angeles, CA."},{"6":"of high quality. : of somewhat high but not excellent quality. : correct or proper. 48 
words 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, 
favorable, 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 
creative solutions for living well and doing good<\/b>."},{"10":"The rise of national socialism in Germany should not be regarded as a 
conspiracy of madmen. Millions of "good<\/b>" people found themselves in a society 
spiralling\u00a0..."},{"11":"We are GOOD's<\/b> social innovation consultancy. We work with organizations to 
imagine bold leadership opportunities that align metrics with social impact."},{"12":"Good<\/b> may refer to: ... This disambiguation page lists articles associated with the 
title 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 
featured 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 
Morning. Check out our main channel for funny music videos, sketches, and 
ridiculo..."},{"15":"Log in to your Network for Good<\/b> account to access donation history, product 
configuration, and more."},{"16":"Good<\/b> Sam Club \u2013 RV Club camping memberships, services, RV Park and 
campground discounts, online travel resources, members only Camping World 
offers,\u00a0..."}]" string(2670) "[[""],{"1":"Synonyms for good<\/b> at Thesaurus.com with free online thesaurus, antonyms, and 
definitions. Dictionary and Word of the Day."},{"2":"A magazine for the global citizen covering stories from business, environment, 
politics, 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
definitions.%20Dictionary%20and%20Word%20of%20the%20Day.%22},{%222%22:%22A%20magazine%20for%20the%20global%20citizen%20covering%20stories%20from%20business,%20environment,%20
politics,%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
child.%206.%20kind,%20beneficent,%20or%20friendly:%20to%20do%20a%20%3Cb%3Egood%3C\/b%3E%20deed.%207.%20honorable%20or%20worthy;%20in
\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
Angeles,%20CA.%22},{%226%22:%22of%20high%20quality.%20:%20of%20somewhat%20high%20but%20not%20excellent%20quality.%20:%20correct%20or%20proper.%2048%20
words%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
favorable,%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
creative%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
conspiracy%20of%20madmen.%20Millions%20of%20&quot;%3Cb%3Egood%3C\/b%3E&quot;%20people%20found%20themselves%20in%20a%20society%20
spiralling\u00a0...%22},{%2211%22:%22We%20are%20%3Cb%3EGOOD&#39;s<\/b> social innovation consultancy. We work with organizations to 
imagine bold leadership opportunities that align metrics with social impact."},{"12":"<b>Good<\/b> may refer to: ... This disambiguation page lists articles associated with the 
title <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 
featured 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 
Morning. Check out our main channel for funny music videos, sketches, and 
ridiculo..."},{"15":"Log in to your Network for <b>Good<\/b> account to access donation history, product 
configuration, and more."},{"16":"<b>Good<\/b> Sam Club \u2013 RV Club camping memberships, services, RV Park and 
campground discounts, online travel resources, members only Camping World 
offers,\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 
definitions. Dictionary and Word of the Day."},{"2":"A magazine for the global citizen covering stories from business, environment, 
politics, 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> 
child. 6. kind, beneficent, or friendly: to do a good<\/b> deed. 7. honorable or worthy; in
\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 
Angeles, CA."},{"6":"of high quality. : of somewhat high but not excellent quality. : correct or proper. 48 
words 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, 
favorable, 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 
creative 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 
conspiracy of madmen. Millions of "
  • 写回答

2条回答 默认 最新

  • dpn68721 2015-11-05 01:39
    关注

    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);
    
    }?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。