I am trying to find a way to add new line between elements of an array. I have a php file which outpust JSON data since I have this line - header('Content-Type: application/json');
Because of this data is always printed in one line, and <p>
,<br>
, are considered as text instead of codes. The while just runs data from a query which insert values into
$vs['title']
and $vs['description']
.
How can I make it print like this :
Title - my title
Value - my value
instead of:
Title - my title Value - my value
Part of PHP File
$vs1=array();
while($res2 = oci_fetch_array($result2)) {
$vs=array();
$vs['title']='Title'.$res2['CATEGORIA_DESC'];
$vs['description']= 'Value - '.$res2['VALOR'];
array_push($vs1,$vs);
}
echo str_replace(array('[', ']'), '', htmlspecialchars(json_encode($vs1), ENT_NOQUOTES));
if you just want display the data, you can do it in the while loop :
while ($res2 = oci_fetch_array($result2)) {
echo "<hr/>";
echo "<div>Title {$res2['CATEGORIA_DESC']}</div>";
echo "<div>Value - {$res2['VALOR']}</div>";
}