Reply to Re: preg_grep question

Your name:

Reply:


Posted by gosha bine on 06/05/07 20:58

On 05.06.2007 22:38 paladin.rithe@gmail.com wrote:
> This is probably simple, but I want to pull out data (not count) from
> a string, and the preg_grep looked like the best option. I'm pulling
> an entry out of the database (which is a text field), a sample being:
> Note #13 for Task #23 added to the system. I want to pull the 13, and
> the 23 out. (probably need 2 different calls, but that's ok).
> The problem that I'm having though is this: Warning: preg_grep()
> expects parameter 2 to be array, string given in table.php on line 18
>
> Here is the code for that line: $note = preg_grep("/^Note #([0-9]+)/",
> $text);
> $text is the value of $row['text'] (tried $row['text'] first, but had
> the same thing).
>
> Now, I thought that something of type text would be a string/array, so
> why doesn't it like it? I'm running PHP 5.2.1 right now, if that
> helps any.
>

You want preg_match or preg_match_all, not preg_grep.

--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация