RE: [PHP] reg ex help

From: Date: Fri, 04 Nov 2005 18:54:29 +0000
Subject: RE: [PHP] reg ex help
Groups: php.general 
Request: Send a blank email to php-general+get-225102@lists.php.net to get a copy of this message
[snip] The problem with that is there are about 40 different listings in the one field. Silver Small Corp;;;;;X^%%%%%\n#####\n Gold Medium Corp;;;;;RE^%%%%%\n#####\n Platinum Large Corp;;;;;YRE^%%%%%\n#####\n being three of them so maybe this is a bettter way of listing it ... Silver Small Corp;;;;;X^%%%%%\n#####\nGold Medium Corp;;;;;RE^%%%%%\n#####\nPlatinum Large Corp;;;;;YRE^%%%%%\n#####\n ...[/snip] Try this: $values = array(); // we'll put the extracted vars here $str = "This is supposed to be your string"; $tmpStr = explode("#\n", $str); foreach ($tmpStr as $foo) { if (strlen(trim($foo)) > 0) { array_push($values, substr($foo, 0, strpos($foo, ';'))); } } HTH, Pablo

« previous php.general (#225102) next »