How to evaluate string?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

How to evaluate string?

Post 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
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

Code: Select all

<?php

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

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



?>
Post Reply