The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End use function variables like wordpress Re: use function variables like wordpress

Rob MacKay

Well – is there any reason why you need to pass them like that firstly? Could you not just create an array and throw that in?

Because I am sure you know this already, that format is how your browser will POST and GET… I am not sure how WP are doing it in their code but I suppose you could explode the data into an array and use it that way…

$var = explode(‘&’, $string);

That would give you an array like


Then you are atleast half way there – maybe then you could split them again…


Was just playing around with a double explode idea and thought I would check the info on explode – and I found this awesome function :D

function doubleExplode ($del1, $del2, $array){

$array1 = explode("$del1", $array);

foreach($array1 as $key=>$value){
$array2 = explode("$del2", $value);
foreach($array2 as $key2=>$value2){
$array3[] = $value2;

$afinal = array();

for ( $i = 0; $i <= count($array3); $i += 2) {
$afinal[trim($array3[$i])] = trim($array3[$i+1]);
return $afinal;

So you basically use it like this…

$string = "title=home&foo=bar&this=that";
$myVar = doubleExplode(‘&’, ‘=’, $string);

and you get back a nice array:

[title] => home
[foo] => bar
[this] => that

Is that more the kind of thing you were looking for? :)

credits to this awesome post: