Jump to content

[SOLVED] function doesn't return if "load" is an array value


baiwan

Recommended Posts

I have created a simple function to load an array with name / value pairs, and return the array. Most of the time it works as expected, but one particular name / value pair causes the function not to return. No errors are reported.

 

My system details:

 

OS: Windows XP SP2 ("Windows NT OFFICE 5.1 build 2600" reported by phpinfo)

Server: XAMPP for windows (apache)

PHP Version: PHP Version 5.1.4

 

The function:

 

function get_jsparams($qs){

$qs=str_replace('%20',' ',$qs);
$parts=explode('{',$qs,20);
foreach ($parts as $v)
{
$vname=substr($v,0,3);
$vval=trim(substr($v,4),'}');
echo $vname.' - ';
echo '"'.$vval.'"<br />';	
if($vval){	$parray[$vname]=$vval;}
}

echo '<pre>';
print_r($parray);
echo '</pre>';
return $parray;
}

 

The calling code:

 

$jsparams=get_jsparams($_SERVER['QUERY_STRING']);
echo '<pre>';
print_r($jsparams);
echo '</pre>';

 

The Query string:

 

{Cvr;1v01}{Sit;oAxb1rhJ5432}{Lod;load}{Wth;1280}{Hth;1024}

 

The function should add name / value pairs to the array and return the array. In this example the first name / value pair should be name=Cvr, value=1v01.

 

The key value here appears to be the "Lod;load" name/value pair. Change either "Lod" or "load" and the function works as expected!

 

This has me mystified! With these values the function fails to return, i.e., the code following the function call is not executed.  ???

 

Any help would be much appreciated!  ::)

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.