Autor | Zpráva | ||
---|---|---|---|
embebito52233 Profil * |
#1 · Zasláno: 16. 7. 2013, 14:16:51
Dobrý den,
chtěl bych se zeptat, jak mám zjistit, jestli v proměnné je daný text. Mám třeba proměnnou $text a v něm text Jmeno: bla - > $text = "Jméno: bla"; Jak mám zjistit, jestli proměnná $text obsahuje slovo "Jméno"? Googloval jsem, ale nemůžu nic najít. Díky moc. |
||
Jan Tvrdík Profil |
#2 · Zasláno: 16. 7. 2013, 14:32:13
embebito52233:
strpos |
||
embebito52233 Profil * |
#3 · Zasláno: 16. 7. 2013, 15:17:25
$najdi = "Jméno"; $y = StrPos($text,$najdi); if($y == false) { die("Chyba"); } |
||
peta Profil |
#4 · Zasláno: 16. 7. 2013, 15:36:56
http://www.php.net/function.strpos
Returns the position of where the needle exists relative to the beginning of the haystack string (independent of offset). Also note that string positions start at 0, and not 1. Returns FALSE if the needle was not found. Warning This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function. Znamena to, ze funkce vraci pozici retezce, cislovane od nuly nebo false. Nula odpovida podmince ==false a ze mas pouzit ===. |
||
Časová prodleva: 11 let
|
0