krot

json_encode null to empty string

Apr 12th, 2019
110
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 );
RAW Paste Data