Advertisement
jiue123

Change value of PHP array with Condition

Sep 14th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.25 KB | None | 0 0
  1. $file = array();
  2.  
  3. $file[0] = 0;
  4. $file[1] = "VietNam";
  5. $file[2] = "";
  6.  
  7. $file = array_map(function($v) { if ($v == 0 || $v == "") {return "NULL";} return $v;}, $file);
  8.  
  9. /* result
  10.     $file[0] = "NULL";
  11.     $file[1] = "VietNam";
  12.     $file[2] = "NULL";
  13. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement