note 37563 added to function.explode

From: Date: Wed, 19 Nov 2003 20:24:32 +0000
Subject: note 37563 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-60638@lists.php.net to get a copy of this message
(please remove my last post! it has a big bug on it) here is a tested case-insensitive explode I named it explodei().works cool :-) 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, paste below function in your code as it's needed for explodei: strpos(), case-insensitive : function stripos( $haystack, $needle, $start = 0) { $haystack = strtolower ( substr($haystack, $start) ); $needle = strtolower ( $needle ); return strpos( $haystack, $needle); } ---- Manual Page -- http://www.php.net/manual/en/function.explode.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37563 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37563&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37563&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#60638) next »