The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
|
#1
|
||||
|
||||
Using preg_match_all...
Hi everyone,
I have a string for example like below: Code:
id:3,name:example,ip:89.12.4.54,sa:false,a:false;id:5,name:exampletwo,ip:78.23.45.61,sa:false,a:true; However, the following doesnt seem to work properly. It works when there is one of the pattern but if more than one the array is created incorrectly. I am inexperienced with preg_match_all, anyone spot how to just isolate the pattern correctly? My code: Code:
// Get array function get_vars($var) { $vars = array(); $pattern = "/id:(.*),name:(.*),ip:(.*),sa:(.*),a:(.*);/si"; // This is the pattern to retrieve in the string if (preg_match_all ($pattern , $var, $matches, PREG_SET_ORDER)) { foreach ($matches as $var) { $vars[] = array ( 'id' => $var[1], 'name' => htmlspecialchars_decode(trim($var[2])), 'ip' => $var[3], 'sa' => $var[4], 'a' => $var[5] ); } } return $vars; } Matt |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|