Page 1 of 1

How to evaluate string?

Posted: Fri Nov 05, 2004 2:47 pm
by ljCharlie
What is the best way to evaluate two variables that contain strings? For example, I want to compare if "a black truck" and "A Black Truck" are both the same thing.

ljCharlie

Posted: Fri Nov 05, 2004 3:07 pm
by rehfeld

Code: Select all

<?php

$str1 = 'A BlACk TruCk';
$str2 = 'a black TRUCK';

if (strtolower($str1) === strtolower($str2)) {
    // they are the same
}



?>