Advertisement
krot

json_encode null to empty string

Apr 12th, 2019
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.19 KB | None | 0 0
  1. $a=[1=>1,'"hj'=>null,'hh'=>[1=>2,'h'=>null]];
  2. array_walk_recursive($a, function  (&$item, $key)
  3. {
  4.     //$item = utf8_encode($item);
  5.     $item=is_null($item)?'':$item;
  6. });
  7. $a=json_encode($a );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement