Page 1 of 1

Replacing integers

Posted: Sun Jan 01, 2006 6:19 am
by anjanesh
$SortBy is an integer

Code: Select all

$Parameters = $_SERVER['QUERY_STRING'];
if (preg_match("/SortBy=([0-9]+)(&|$)/i", $Parameters, $matches) > 0)
 {
        $Parameters = str_replace($matches[0], "SortBy=".$SortBy.$matches[2], $Parameters);
 }
If I replace line 4 with

Code: Select all

$Parameters = str_replace($matches[1], $SortBy, $Parameters);
then $Parameters is setting some other value for SortBy

Is this because $SortBy is an integer ? The first one is treated as a string because its concatenated with dot(.)s.

Thanks