You are here: Re: preg_grep question « PHP Programming Language « IT news, forums, messages
Re: preg_grep question

Posted by gosha bine on 06/05/07 21:46

paladin.rithe@gmail.com wrote:
> On Jun 5, 4:58 pm, gosha bine <stereof...@gmail.com> wrote:
>> On 05.06.2007 22:38 paladin.ri...@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
>
> But I want to pull the data out. I know it's already there.
> preg_match just tells me how many matches there are (in this case, 1)
>

I'd suggest you just read documentation

http://php.net/preg_match
http://php.net/preg_match_all
http://php.net/preg_grep

--
gosha bine

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

 

Navigation:

[Reply to this 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

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