/ Published in: PHP
URL: http://nothingconcept.com
Expand |
Embed | Plain Text
<?php /* Function: eexplode Explodes an string and removes any empty elements in the resulting array Parameters: $separator - The separator used to explode the $string $string - The string to explode Returns: An array with no empty elements Example: print_r(explode(":","evan:walsh:")); Array( [0] => evan [1] => walsh [2] => ); print_r(eexplode(":","evan:walsh:")); Array( [0] => evan [1] => walsh ); */ function eexplode($separator,$string){ foreach($array as $key => $val){ } } return $array; }
Comments
Subscribe to comments
You need to login to post a comment.

You may be interested in mapping the exploded array with trim to avoid a situation like this:
Some thoughts:
You could also do something like this, but it all depends on if you want to maintain breaks, spaces, tabs, etc ...