note 37563 deleted from function.explode by bjori

From: Date: Mon, 25 Sep 2006 08:13:04 +0000
Subject: note 37563 deleted from function.explode by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-117606@lists.php.net to get a copy of this message
Note Submitter: siavash79_99 at yahoo dot com ---- here is a tested case-insensitive explode I named it explodei().works cool :-) <?php function explodei($separator, $string, $limit = false ) { $len = strlen($separator); for ( $i = 0; ; $i++ ) { if ( ($pos = stripos( $string, $separator )) === false || ($limit !== false && $i > $limit - 2 ) ) { $result[$i] = $string; break; } $result[$i] = substr( $string, 0, $pos ); $string = substr( $string, $pos + $len ); } return $result; } ?> If your php version is under 5, you'll need to add stripos() to your script. See http://php.net/function.stripos

« previous php.notes (#117606) next »