note 17081 modified in function.explode by zak

From: Date: Sun, 25 Nov 2001 00:17:49 +0000
Subject: note 17081 modified in function.explode by zak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-21257@lists.php.net to get a copy of this message
Multiple tokens making explode behave in undesirable ways? Try the following code: function tc_explode ($token, $string) { ....$regex = preg_quote ($token); ....$string = preg_replace("/$regex+/", $token, $string); ....return explode($token, $string); } Note: .'s added for indenting - remove before use! :) --was-- To go around the problem of multiple spaces while separating by spaces (common problem for search) I reccomend this code: $szSearch = eregi_replace("( ){1,}",",",$szSearch); $keywords = explode(",",$szSearch); worked fine for me http://www.php.net/manual/en/function.explode.php

« previous php.notes (#21257) next »