Artificial intelligence

TO EVERYBODY


Logo

We are reinventing the world of tomorrow thanks to Artificial Intelligence


But what artificial intelligence are we talking about ?

PHP strtoupper()

PHP versions can sometimes have bugs.


Here is an alternative function to the PHP function strtoupper which works perfectly.


<?php
 
function str_to_upper($Chaine)
{
    $Alphabet_minuscules = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
 
    $Chaine = htmlentities($Chaine);
 
    for($l = 0; $l < strlen($Chaine); $l++)
    {
        if(in_array($Chaine[$l], $Alphabet_minuscules))
        {
            $Chaine[$l] = strtoupper($Chaine[$l]); // Ne pas transformer par str_to_upper !!!!!!!!!!!!!!!!!!
        }
    }
 
    preg_match_all('#&(.*?);#is', $Chaine, $resultat, PREG_PATTERN_ORDER);
 
    foreach($resultat[1] as $entities)
    {
        if(strlen($entities) > 3)
        {
            $html_entities = '';
 
            for($i = 0; $i < strlen($entities); $i++)
            {
                if($i > 0)
                {
                    $html_entities[$i] = strtolower($entities[$i]);
                }
                else
                {
                    $html_entities[$i] = $entities[$i];
                }
            }
 
            $Chaine = str_replace($entities, $html_entities, $Chaine);
        }
    }
 
    $Chaine = html_entity_decode($Chaine);
 
    return $Chaine;
}
 
?>

<?php
 
	$Chaine = 'eaucé~àEric éèàçù';
 
        echo $Chaine . '<br /><br />';
 
        echo strtoupper($Chaine) . '<br /><br />';
 
        echo str_to_upper($Chaine);
 
?>
 
		Résultat / result
 
	$Chaine      => eaucé~àEric éèàçù
 
	strtoupper   => EAUCé~àERIC éèàçù
 
	str_to_upper => EAUCÉ~ÀERIC ÉÈÀÇÙ
 
 

strtoupper - Returns a string in UPPERCASE