detecting \ in a 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
nincha
Forum Contributor
Posts: 191
Joined: Fri Mar 28, 2003 12:30 pm
Location: CA, USA

detecting \ in a string

Post by nincha »

Any one have any ideas?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

take a look at strpos() for your easiest solution....
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

You beat me to it, but more specifically, try this snippet:

Code: Select all

<?php
  if (strpos($yourstring, '\\') === FALSE) {
    echo 'Your string does not contain \\';
  } else {
    echo 'Your string does contain \\';
  }
?>
Post Reply