php - Json encode with strips html tags -


how strip html tags complete row json_encode

<?php     $return_arr = array();     $sql="select *  products ";     $results=$conn->query($sql);      if($results->num_rows > 0) {         while($rowz = $results->fetch_assoc()){              array_push($return_arr, $rowz);         }     }      echo json_encode($return_arr); ?> 

my output field like( "<.p>"lorem ipsum<./p>lorem lorem lorem <./br>.....")

strip_tags require string not array

you can use following code:

<?php  $array = array(     '<p>hello</p>'     );  array_walk_recursive($array, function (&$val) { $val = strip_tags($val); });  echo json_encode($array); ?> 

above code, in array_walk_recursive array values , strip html tags.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -