How to wrap the while loop in JSON?

As it all wrapped in a JSON array?

<? $get_notifications = $mysqli--->query('SELECT * FROM `notifications_fromsite`); # Get the notification

 if($get_notifications->num_rows !== 0) {
 while($value = $get_notifications->fetch_array()) {
 ?><a class="list-group-item media" data-notification="<?=$value['id'];?>">
 <div class="pull-left">
 <div class="notifications_item_icon notifications_item_icon8"></div>
</div>
 <div class="media-body">
 <div class="lgi-heading"><?=date('d.m.y', $value['unixtime_create']);?></div>
 <small class="lgi-text"><?=$value['text'];?></small>
</div>
</a><?
 }</property-->
June 7th 19 at 14:28
1 answer
June 7th 19 at 14:30
even though a string array
I'm in my SPA, do I send the data from the query without execution of(mobile traffic saving)) )
$sth=mysqli_query($link,$sql); 
$rows = array();
while($r = mysqli_fetch_assoc($sth)) {
$rows[] = $r;
}
print json_encode($rows);

and "Doris" from js
That's not what I need - Zachariah_Weima commented on June 7th 19 at 14:33
still tell me what you want to achieve
telepaths a - jalon_Gorczany commented on June 7th 19 at 14:36
, 5a9af4a929cf4913103431.png
Here it is I need to wrap it in JSON - Zachariah_Weima commented on June 7th 19 at 14:39
it is clear almost a verbatim repetition of the question was not a drop
needs to send a text? - get to a string and encoded string json_encode - jalon_Gorczany commented on June 7th 19 at 14:42
can be an example? - Zachariah_Weima commented on June 7th 19 at 14:45
$text=<<<text <a class="list-group-item media" data-notification="<?=$value['id'];?>">
 <div class="pull-left">
 <div class="notifications_item_icon notifications_item_icon8"></div>
</div>
 <div class="media-body">
 <div class="lgi-heading"><?=date('d.m.y', $value['unixtime_create']);?></div>
 <small class="lgi-text"><?=$value['text'];?></small>
</div>

TEXT;
print json_encode($text);</text>
- jalon_Gorczany commented on June 7th 19 at 14:48
, <<<text< code><br> Exactly is PHP?</text<> - Zachariah_Weima commented on June 7th 19 at 14:51
is php your here docs
php.net/manual/ru/language.types.string.php#langua... - jalon_Gorczany commented on June 7th 19 at 14:54
some kind of bad code - Zachariah_Weima commented on June 7th 19 at 14:57
XS where the two lines of code, the bad code
and about your here docs - namuchaetes with shielding, too, will start to use it )) - jalon_Gorczany commented on June 7th 19 at 15:00

Find more questions by tags PHP