Explode() Replacement





6
Date Submitted Fri. Aug. 25th, 2006 4:01 AM
Revision 1 of 1
Helper Cyber-Drugs
Tags explode | foreach
Comments 0 comments
Ever used the Explode() function, and in some parts of the returned array, are NULL values? Below is a function which will only return values which are not NULL. Depending on what you are trying to achieve, this could turn out to be useful.

<?php
    function myFunction($seperator, $string){
    $tmp = explode($seperator, $string);
    foreach($tmp as $val)
        if($val !== "") $arr[] = $val;
    return $arr;
}
?>
 

Justin Nel

Comments

There are currently no comments for this snippet.

Voting