Skip to content

Instantly share code, notes, and snippets.

@zhwei
Last active March 27, 2017 13:14
Show Gist options
  • Save zhwei/51b5846a918880538c00c11696087a21 to your computer and use it in GitHub Desktop.
Save zhwei/51b5846a918880538c00c11696087a21 to your computer and use it in GitHub Desktop.
PHP 的坑

== && ===

>>> '233' == '233 '
=> false
>>> '233' == ' 233'
=> true
>>> '233' === ' 233'
=> false

numberic

>>> is_numeric(' 233')
=> true
@zhwei
Copy link
Author

zhwei commented Mar 27, 2017

array_walk

>>> $a = explode(' ', '1 2 3');
=> [
     "1",
     "2",
     "3",
   ]
>>> array_walk($a, 'intval')
=> true
>>> $a
=> [
     "1",
     "2",
     "3",
   ]
>>> $a = array_map('intval', $a)
=> [
     1,
     2,
     3,
   ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment