06-15-2008, 11:02 PM
|
#4 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
Yes, sorry, my bad. I forgot to put a line in a conditional statement. Try:
php Code:
$szString = "501,bleh,{ itemheal rand(45,65),0; },bleh,1,2,3,{ohh,1,2}"; print_r(picky_explode (',', $szString)); function picky_explode ($szSplitBy, $szString){ $bInBrackets = false; $aParts = explode($szSplitBy, $szString); $aReturn = array(); foreach ($aParts as $szPart) { if (! $bInBrackets) { $aReturn[] = $szPart; } if (substr($szPart, 0, 1) == '{') { $bInBrackets = true; continue; } if ($bInBrackets) { $aReturn[count ($aReturn) - 1] .= $szSplitBy . $szPart; } if (substr($szPart, - 1, 1) == '}') { $bInBrackets = false; } } return $aReturn; }
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|