I want to encode data retrieved from database into json. Here is my codes..
<?php
$con = mysqli_connect("localhost", "root", "", "joomla");
if($con === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$sql = "SELECT * FROM yv084_content";
$result = mysqli_query($con, $sql);
$all_result = array();
$intro_result = array();
$num_rows = mysqli_num_rows($result);
$count =0;
while($row = mysqli_fetch_assoc($result)){
$all_result[] = $row;
}
while($count<$num_rows){
$intro_result[] = strip_tags($all_result[$count]['introtext']);
//echo strip_tags($all_result[$count]['introtext'])."<hr />";
$count++;
}
echo "<hr />";
var_dump($intro_result);
echo "<hr />";
$encoded_value = json_encode($intro_result);
var_dump($encoded_value);
echo $encoded_value;
when I use var_dump
function, then i got proper result but when i use json_encode
function to encode that array it is returning false.. Is there any idea how to encode them..
Note: There is alot of special characters and html entities so I am using strip_tags
function.
please review the result what I got in the browser...