Misusing The URLENCODE/DECODE() Functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi List

I usually don't tend to post here but I have no time and no idea :(

I'm using .htaccess and a php router file (based upon regex patterns) in
order to create google-friendly URL's

It works like a charm, but somehow it has decoding '+' signs and similar
things into the appropriate character

For instance, I'm trying to reach this page:
A%252bk/ASTROBEAM_S130.html


It's being parsed by the following regex pattern:
'bulb/(.+/.+)\.html' => 'index.php?a=lamp_by_model&model=$1',

The loaded page PHP content is:
list($make, $model) = parse_model_slug($_GET['model']);

The parse_model_slug() function:
function parse_model_slug($slug)
{
    $r = explode("/", $slug);
    $r[0] = str_replace("_", " ", $r[0]);
    $r[1] = str_replace("_", " ", $r[1]);
    var_dump($r);
    die;
    return array('make' => $r[0], 'model' => $r[1]);
}

The current output is:
A%252bk/ASTROBEAM_S130

array(2) {
  [0]=>
  string(7) "A%252bk"

  [1]=>
  string(14) "ASTROBEAM S130"
}


Then whenever I add urldecode() to the function:
function parse_model_slug($slug)
{
	$r = explode("/", $slug);
	$r[0] = str_replace("_", " ", urldecode($r[0]));

	$r[1] = str_replace("_", " ", urldecode($r[1]));
	var_dump($r);
	die;
	return array('make' => $r[0], 'model' => $r[1]);
}



A%252bk/ASTROBEAM_S130array(2) {

  [0]=>
  string(5) "A%2bk"
  [1]=>
  string(14) "ASTROBEAM S130"
}


I have no idea how to parse this string right.

Any help would be highly appreciated!!

--
Nitsan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux