I need to replicate the method of converting > into   > Â.
I have a constant defined which is used as the separator between a child and parent category.
define('CATEGORY_SEPERATOR', ' > ') // (constant may vary)
$sql .= "GROUP_CONCAT(c.name ORDER BY c.level SEPARATOR "'" . CATEGORY_SEPERATOR ."'") AS name
A possible result could be
row = array(
'name => category1 > category2
)
The categories are then displayed as a list of links
<li><a href="www.example.com/categories?&name=<?php echo $row['name'];?>"><?php echo $row['name'];?></a></li>
when a link is clicked the URLS are encoded.
addressbar: `www.example.com/categories?name=category1 > category2
I want to be able to check whether the CATEGORY_SEPERATOR exists within $_GET['name'] . so I can perform
$name = $_GET['name'];
$categories = explode(CATEGORY_SEPERATOR, $name);
but by the time $_GET['name'] reaches my script its beet transformed.
$_GET['name'] initial value
var_dump : string 'category1Â Â >Â Â category2' (length=27)
After stripslashes() (no change)
var_dump : string 'category1Â Â >Â Â category2' (length=27)
After htmlspecialchars($data, ENT_COMPAT, 'UTF-8');
var_dump : string 'category1Â Â >Â Â category2' (length=30)
Now i've managed to reverse it slightly by doing the following
$_GET['name'] = htmlspecialchars_decode($_GET['name'], ENT_COMPAT);
if(ini_get('magic_quotes_gpc')){
$_GET['name'] = addcslashes($_GET['name']);
}
But still need to get it from
category1Â Â >Â Â category2 to >
Ive tried using urldeocde and rawurldecode, without any luck.