i want to encode a json because it contains special characters
I try to use simple urlencode but it doesn't work. When I print the variable in alert on the js is empty
$sql="select name,surname from agents";
$res = $conn->query($sql);
while($row = $res->fetch_assoc())
{
$rows[] = $row;
}
$json = json_encode($rows);
echo urlencode($json);
$rows[] = $rowto$rows[] = json_encode($row)$json?var agents = <?=$json?>;