if / in var tu das ->

Neo

Erfahrenes Mitglied
Hallo

Sorry bisschen eigenartiger titel aber ich dachte ist am besten um mich auszudrücken:

also kann mir bitte jemand sagen wie ich ein entscheid mache wenn eine variable ein / im namen enthält?

also ca.

Code:
if ($var enthält ein / oder \);

{


tu dies

}


Vielen Dank für hilfe im voraus!!!!
 
Referenz: http://www.php.net

strstr

(PHP 3, PHP 4 )
strstr -- Find first occurrence of a string

Description
string strstr ( string haystack, string needle)

Returns part of haystack string from the first occurrence of needle to the end of haystack.

If needle is not found, returns FALSE.

If needle is not a string, it is converted to an integer and applied as the ordinal value of a character.


Note: This function is case-sensitive. For case-insensitive searches, use stristr().


Example 1. strstr() example
$email = 'user@example.com';
$domain = strstr($email, '@');
print $domain; // prints @example.com

url:
http://www.php.net/manual/en/function.strstr.php


gruß,
Neuro
 
*sniff* sorry bin noch zu sehr neuling und unbewandert... :rolleyes: is jemand so freundlich und kann mir helfen das auf mein beispiel anzupassen? :p

thx schonaml viiielmal!
 
bitte sehr:

PHP:
<? 
$string = "text mit / oder \ drin";

if (strstr($string, '/') OR strstr($string, '\\')) {
	echo "jau, ist drin";
} else {
	echo "nope";
}
?>

:o)

***edit***
*argh* beim zweitem strstr müssen ZWEI (!) \ rein, irgendwie hat das board damit wohl probs ... :(
***edit***
 
Zuletzt bearbeitet:
Zurück