<?php
int strcoll ( str $str1 , str $str2 )
where,
$str1 = The first STRING to compare
$str2 = The second STRING to compare
?>
CONSTANTS | USES |
LC_ALL | FOR ALL VARIABLES |
LC_COLLATE | Comparisons with STRINGS See, strcoll |
LC_CTYPE | Conversion and Classification of Characters See, strtoupper |
LC_MONETARY | Monetary Standards See, localeconv |
LC_NUMERIC | Decimal Separator See, localeconv |
LC_TIME | Date and Time Formatting with strftime |
LC_MESSAGES | System Responses Available if PHP was compiled with libintl |
ed48 |
<?php
setlocale(LC_COLLATE, 'C');
function str_coll1 ($par1, $par2)
{
$stcmp12 = strcoll($par1, $par2);
if ($stcmp12 > 0)
{
echo 'Returned value: ' . $stcmp12 .
'<br>therefore,<br>' . $par1 .
'<br>is GREATER than<br>' . $par2 . '<br><br>';
}
elseif ($stcmp12 < 0)
{
echo 'Returned value: ' . $stcmp12 .
'<br>therefore,<br>' . $par1 .
'<br>is LESS than<br>' . $par2 . '<br><br>';
}
else
{
echo 'Returned value: ' . $stcmp12 .
'<br>therefore,<br>' . $par1 .
'<br>is EQUAL to<br>' . $par2 . '<br><br>';
}
}
$srcm01 = 'Augusta';
$srcm02 = 'AUGUSTA';
$srcm03 = 'angusta';
$srcm04 = 'angusta';
str_coll1($srcm01, $srcm02);
str_coll1($srcm01, $srcm03);
str_coll1($srcm03, $srcm01);
str_coll1($srcm03, $srcm04);
?>
<?php
setlocale (LC_ALL, 'pt_PT', 'ptg', 'portuguese');
$srcm01 = "abcdefàáãç";
$srcm02 = "abcdefàá";
function str_coll12 ($par1, $par2)
{
$stcmp12 = strcoll($par1, $par2);
if ($stcmp12 > 0)
{
echo 'Returned value: ' . $stcmp12 .
'<br>therefore,<br>' . $par1 .
'<br>is GREATER than<br>' . $par2 . '<br><br>';
}
elseif ($stcmp12 < 0)
{
echo 'Returned value: ' . $stcmp12 .
'<br>therefore,<br>' . $par1 .
'<br>is LESS than<br>' . $par2 . '<br><br>';
}
else
{
echo 'Returned value: ' . $stcmp12 .
'<br>therefore,<br>' . $par1 .
'<br>is EQUAL to<br>' . $par2 . '<br><br>';
}
}
str_coll12($srcm01, $srcm02);
echo 'or<br><br>';
str_coll12($srcm02, $srcm01);
?>
<?php
setlocale (LC_ALL, '');
$srcm01 = "SÃO PAULO";;
$srcm02 = "São Paulo";
function str_coll13 ($par1, $par2)
{
$stcmp12 = strcoll($par1, $par2);
if ($stcmp12 > 0)
{
echo 'Returned value: ' . $stcmp12 .
'<br>therefore,<br>' . $par1 .
'<br>is GREATER than<br>' . $par2 . '<br><br>';
}
elseif ($stcmp12 < 0)
{
echo 'Returned value: ' . $stcmp12 .
'<br>therefore,<br>' . $par1 .
'<br>is LESS than<br>' . $par2 . '<br><br>';
}
else
{
echo 'Returned value: ' . $stcmp12 .
'<br>therefore,<br>' . $par1 .
'<br>is EQUAL to<br>' . $par2 . '<br><br>';
}
}
str_coll13($srcm01, $srcm02);
echo 'or<br><br>';
str_coll13($srcm02, $srcm01);
?>
<?php
setlocale (LC_ALL, 'en_US');
$srcm01 = 'Many hands make light work.';
$srcm02 = 'MANY HANDS MAKE LIGHT WORK.';
function str_coll14 ($par1, $par2)
{
$stcmp12 = strcoll($par1, $par2);
if ($stcmp12 > 0)
{
echo 'Returned value: ' . $stcmp12 .
'<br>therefore,<br>' . $par1 .
'<br>is GREATER than<br>' . $par2 . '<br><br>';
}
elseif ($stcmp12 < 0)
{
echo 'Returned value: ' . $stcmp12 .
'<br>therefore,<br>' . $par1 .
'<br>is LESS than<br>' . $par2 . '<br><br>';
}
else
{
echo 'Returned value: ' . $stcmp12 .
'<br>therefore,<br>' . $par1 .
'<br>is EQUAL to<br>' . $par2 . '<br><br>';
}
}
str_coll14($srcm01, $srcm02);
echo 'or<br><br>';
str_coll14($srcm02, $srcm01);
?>
<?php
$a = 'a';
$b = 'A';
setlocale (LC_COLLATE, 'C');
$result = strcoll($a, $b);
if($result > 0) {
echo "Pass\n";
}
?>