When I am trying to echo json in php it returns \t . How I can remove them?
Here is my code:
ob_start();
$this->load->view('competition/template',$q);
$content = ob_get_clean();
$data['content'] = $content;
echo json_encode($data);
And am getting:
</table>{"ok":1,"content":"<table>
<tr>
\t <td>Competitor name<\/td>
\t <td><input type=\"text\" name=\"competitor_name[2]\" \/><\/td>
<\/tr>
<tr>
<\/tr>
<tr>
<\/tr>
<tr>
<\/tr>
<\/table>"}
This is the template.php file:
<table>
<tr>
<td><?php echo $this->__('Competitor name');?></td>
<td><input type="text" name="competitor_name[<?php echo $id?>]" /></td>
</tr>
</table>
After str_replace or preg_repalce, am getting:
{"ok":1,"content":"<table> <tr> <td>Competitor name<\/td> <td><input type=\"text\" name=\"competitor_name[1]\" \/><\/td> <\/tr> <\/table>"}
Now my problem is \.
Thank you.
Ok I found the anwser. Here it is:
$content = preg_replace("@[\|\
|\\t|\\/|\\\"]+@", "", $content);
But am not sure why I was getting this problem .