Created
March 11, 2013 14:20
-
-
Save Sitebase/5134567 to your computer and use it in GitHub Desktop.
Use array explode in combination with list and support different number of array items. In this example $params can have one, two or three items. Not set items will be null.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list($field1, $field2, $field3) = array_pad(explode('.', $params, 3), 3, NULL); |
Author
Sitebase
commented
Mar 11, 2013
- It limits the size of the array returned by explode() to 2
- If there are fewer than two values returned, it appends null until the array contains 2 values.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment