2011/7/8 Rafael Dohms <lis...@rafaeldohms.com.br>:
> Still, this is preg_match it only returns one match, why should i get
> a array and have to use ugly things like $matches[0] afterwards?
> It just makes for very ugly syntax and extra code, a simple function
> would make this cleaner and more intuitive, first time using
> preg_match is a nightmare.
>

You forget about subpatterns, so array can contain more than 1 value:
php > preg_match('/p(hp)/', 'php', $matches); var_dump($matches);
array(2) {
  [0]=>
  string(3) "php"
  [1]=>
  string(2) "hp"
}


> --
> Rafael Dohms
> PHP Evangelist and Community Leader
> http://www.rafaeldohms.com.br
> http://www.phpsp.org.br
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
Regards,
Shein Alexey

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to