PHP Function Equivalents
"Closest API" and "idiomatic" equivalents aren't always the same thing — each page below shows both, along with the behavioral differences that matter.
-
Arraysarray_map()What Python's map() and list comprehensions do differently from PHP's array_map(), with working examples.
-
Arraysarray_filter()What Python's filter() and list comprehensions do differently from PHP's array_filter(), including key preservation and default-callback behavior.
-
Arraysin_array()Python's `in` operator as the equivalent of PHP's in_array(), and why PHP's loose-comparison type juggling has no direct Python parallel.
-
Stringsexplode()Python's str.split() as the equivalent of PHP's explode(), including differences in limit behavior and empty-string handling.
-
Stringsimplode()Python's str.join() as the equivalent of PHP's implode(), including the reversed argument order and non-string element handling.
-
Stringsstrpos()Python's str.find() and the `in` operator as equivalents of PHP's strpos(), including the critical difference in how "not found" is signaled.
-
Stringssubstr()Python's slice syntax as the equivalent of PHP's substr(), including out-of-range and negative-length handling differences.
-
Stringstrim()Python's str.strip() as the equivalent of PHP's trim(), including the default whitespace character set differences.
-
JSONjson_encode()Python's json.dumps() as the equivalent of PHP's json_encode(), including associative-array-vs-dict and object-vs-array output differences.
-
JSONjson_decode()Python's json.loads() as the equivalent of PHP's json_decode(), including PHP's default stdClass-vs-array output and error-handling differences.
-
Variablesisset()Why PHP's isset() has no single Python equivalent — dict.get(), the `in` operator, and try/except KeyError all cover different parts of what isset() does.
-
Variablesempty()Python's `not` operator (truthiness check) as the equivalent of PHP's empty(), and where PHP's specific falsy-value list diverges from Python's.
No functions match these filters.