2015-11-05 3 views
0

Я использовал этот код для кодирования:PHP JSON декодирования массива строк

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

Мои кодированные данные var_dump ($ прод) является:

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...... 

И отправить эти данные через URL с помощью этого кода на другую страницу:

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

My Url является:

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..."}] 

для получения этих данных я использовал:

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

}?> 

Теперь, когда я его расшифровать это шоу Null

Но если я использую var_dump($array5); то не показывают полный result.It показывает:

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 " 
+0

вы можете вставить var_dump вашего array_chunk ($ arr_content, 1, правда) – ThomasP1988

+0

отредактировать его в моей теме – SOURAV

+0

строки (2670) "[[" "], { «1»: «Синонимы хорошего <\/b> на Thesaurus.com с бесплатным онлайн-тезаурусом, антонимами и \ nопределениями. «Словарь и Слово дня».}, {«2»: «Журнал для глобального гражданина, рассказывающий истории из бизнеса, окружающей среды, политики, искусства, дизайна, культуры, технологий, образования, городских проблем и последних лет. .. "}, {" 3 ":" Хорошо <\/b> что вы здесь. Его верительные грамоты хороши <\/b>. 5. хорошо себя ведет: хорошо <\/b> \ nchild. 6. добрый, благотворный или дружелюбный: делать добро <\/b> дело. 7. почетный или достойный; в \ n \ u00a0 ... "}, {" 4 ":" Безопасная мобильность – SOURAV

ответ

3

Использование urlencode() при генерации контента, а затем urldecode при получении содержимого может помочь, я думаю.

$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); 

}?> 
+0

Спасибо, что это работает :) – SOURAV

2

IMO не рекомендуется хранить столько данных в строке запроса. Вы можете использовать переменную сессии вместо:

# Encoding file 

session_start(); 
$_SESSION['temp_content'] = json_encode(array_chunk($arr_content, 1, true)); 
header("Location: search.php"); 

# Receiving file 

session_start(); 
if (!empty($_SESSION['temp_content'])) { 
    $contents = json_decode($_SESSION['temp_content']); 
    var_dump($contents); 
    unset($_SESSION['temp_content']); 
} 
Смежные вопросы