note 73523 modified in function.explode by bobby

From: Date: Tue, 27 Feb 2007 20:01:25 +0000
Subject: note 73523 modified in function.explode by bobby
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-123933@lists.php.net to get a copy of this message
insensitive case explode function: <?php function iExplode($Delimiter, $String, $Limit = '') { $Explode = array(); $LastIni = 0; $Count = 1; if (is_numeric($Limit) == false) $Limit = ''; while ( false !== ( $Ini = stripos($String, $Delimiter, $LastIni) ) && ($Count < $Limit || $Limit == '')) { $Explode[] = substr($String, $LastIni, $Ini-$LastIni); $LastIni = $Ini+strlen($Delimiter); $Count++; } $Explode[] = substr($String, $LastIni); return $Explode; } ?> --was-- Sorry my previous post have a bug, this is a better version of insensitive case explode function : <?php function iExplode($Delimiter, $String, $Limit = '') { $Explode = array(); $LastIni = 0; $Count = 1; if (is_numeric($Limit) == false) $Limit = ''; while ( false !== ( $Ini = stripos($String, $Delimiter, $LastIni) ) && ($Count < $Limit || $Limit == '')) { $Explode[] = substr($String, $LastIni, $Ini-$LastIni); $LastIni = $Ini+strlen($Delimiter); $Count++; } $Explode[] = substr($String, $LastIni); return $Explode; } ?> http://php.net/manual/en/function.explode.php

« previous php.notes (#123933) next »