Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Wyrażenia regularne
lDoran
post
Post #1





Grupa: Zarejestrowani
Postów: 172
Pomógł: 13
Dołączył: 15.11.2009

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


Chciałbym wyciągnąć wartość value z tego ciągu:
Kod
input type="hidden" id="referredby" name="referredby" value="http://devldoran.wordpress.com/wp-admin/post-new.php"

mój kod:
  1. ...
  2. preg_match('/input type="hidden" id="referredby" name="referredby" value="(.*?)"/', $input, $output);
  3. $this->_aTokens['referredby'] = $output[1];
  4. ...

niestety indeks tablicy $output[1] jest pusty
Kod
array(2) { [0]=>  string(62) "input type="hidden" id="referredby" name="referredby" value=""" [1]=>  string(0) "" }

WTF?! (IMG:style_emoticons/default/sciana.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Fantazyn
post
Post #2





Grupa: Zarejestrowani
Postów: 135
Pomógł: 38
Dołączył: 24.02.2007
Skąd: Warszawa

Ostrzeżenie: (10%)
X----


Taki kod:
  1. $input = 'input type="hidden" id="referredby" name="referredby" value="http://devldoran.wordpress.com/wp-admin/post-new.php"';
  2. preg_match('/input type="hidden" id="referredby" name="referredby" value="(.*?)"/', $input, $output);
  3. var_dump($output);

wyświetla mi:
  1. 0 => string 'input type="hidden" id="referredby" name="referredby" value="http://devldoran.wordpress.com/wp-admin/post-new.php"' (length=114)
  2. 1 => string 'http://devldoran.wordpress.com/wp-admin/post-new.php' (length=52)


Więc to nie wina wyrażenia regularnego, tylko...

Porównaj u siebie zmienną output[1].

Dlaczego u Ciebie:
zmienna ma wartość: input type="hidden" id="referredby" name="referredby" value=""

Nie masz w niej wpisanej wartości value...

Edit: a możesz zrobić var_dump zmiennej $input przed wrzuceniem jej do prega?

Ten post edytował Fantazyn 20.10.2010, 11:42:07
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: 11.10.2025 - 08:53