Answer the question
In order to leave comments, you need to log in
And how to split into 5 paragraphs Php?
$get = file_get_contents("http://api.test.net/json.aspx?AppId={myid}&Query=test&Sources=Web&Market=en-US&WebFileType=%27HTML%27&web.offset=1&Web.Count=20");
$decode = json_decode($get, TRUE); // TRUE for in array format
foreach($decode['SearchResponse']['Web']['Results'] as $res) {
$str = $res['Description'];
for($i = 1; $i <= 20; $i++) {
echo $str.$i.' ';
if ($i==7 || $i==3 || $i==2 || $i==4 || $i==4){
echo '</p><p>';
}
}
1 paragraph - here 7 first results
2 paragraph - here 3 next results
3 paragraph - here 2 next results
4 paragraph - here 4 next results
5 paragraph - here 4 next results
Answer the question
In order to leave comments, you need to log in
how to split text into 5 parts php?
in general, you need to cut the array with the results (array_slice) and only then deal with the generation of html. First we process the data and then only render it, it will be much easier this way.
You did not open the paragraph before the loop and did not close it after it.
It turns out that it will work correctly for you at least from the second line
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question