Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] alternatywa strstr i jego 3 parametru
mefjiu
post
Post #1





Grupa: Zarejestrowani
Postów: 313
Pomógł: 5
Dołączył: 22.03.2005

Ostrzeżenie: (0%)
-----


Potrzebuje funkcję która która odetnę ciąg od 1 napotkanego znaku ale w lewo

Funkcja strstr() posiada optymalny 3 parametr
before_needle

If TRUE (the default is FALSE), strstr() returns the part of the haystack before the first occurence of the needle .

ale problem jest taki że:
5.3.0 Added the optional parameter before_needle .

jest coś innego ?

muszę uzyskać dosłownie coś identycznego
  1. <?php
  2. $user = strstr($email, '@', true);
  3. echo $user; // prints name
  4. ?>

ale odrazu pisze że nie jest mi to potrzebne do walidacji adresu email.

Proszę o wszelką pomoc

Ten post edytował mefjiu 16.04.2008, 11:29:44
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
ayeo
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 1 202
Pomógł: 117
Dołączył: 13.04.2007
Skąd: 127.0.0.1

Ostrzeżenie: (0%)
-----


No, ja chyba też przesadziłem z tym :

  1. <?php
  2. $new = substr($email, 0, strlen($email) - strlen(strstr($email,"@")));
  3. ?>


Zupełnie zapomniałem o strpos();
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 6.10.2025 - 00:19