I needed this same functionality for my soon to be released Geshi Max snippet to have an array in the snippet to highlight specific line numbers. Here’s how I solved my problem...
I created a folder in the assets folder named helperfunctions.
Inside that folder I have a file which holds all my specific functions.( I got this function from the php.net site) This particular function is as follows:
function explodearray($delimeter, $string){
for ($i = 0; $i < strlen($string); $i++){
if ($string{$i} == '"'){
if ($insidequotes)
$insidequotes = false;
else
$insidequotes = true;
}else if ($string{$i} == $delimeter){
if ($insidequotes){
$currentelement .= $string{$i};
}else{
$returnexplodearray[$elementcount++] = $currentelement;
$currentelement = '';
}
}else{
$currentelement .= $string{$i};
}
}
$returnexplodearray[$elementcount++] = $currentelement;
return $returnexplodearray;
}
Then in my snippet which needs to grab the parameters I used the tip provided by OpenGeek (linked in post above) to include the function file.
include_once($modx->config[’base_path’] . ’assets/frsfunctions/frsfunctions.php’);
$newarray =explodearray(",", $sarray);
the snippet call is like so: [[snippet?sarray=1,4,9,10,20]]