troubleshooting Question

php - identical strings don't show up as a match

Avatar of n00b0101
n00b0101 asked on
PHPRegular Expressions
4 Comments1 Solution284 ViewsLast Modified:
I'm trying to determine whether or not two strings match, and even though when I print them out, they're identical, it still says they don't match.  I tried to cast them both as strings, and I tried using '===' instead of '==', but neither solved the problem...

       if(preg_match("#^Availability:#", $test)) {
        //just to note: $test = "Availability: Lorem Ipsum";
        $nid = 1;
        $prep = explode("Availability:", $test);
        $orig = node_load($nid);
        print $prep[1];  //Prints Lorem Ipsum
        print($orig->title); //Prints Lorem Ipsum
        if((string)$orig->title	== (string)$prep[1]) { 
          print 'ok'; 
        } else { 
          print 'nope'; //Always prints nope

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros