|
Posted by paladin.rithe@gmail.com on 06/06/07 11:32
On Jun 5, 5:46 pm, gosha bine <stereof...@gmail.com> wrote:
> paladin.ri...@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_matchhttp://php.net/preg_match_allhttp://php.net/preg_grep
>
> --
> gosha bine
>
> extended php parser ~http://code.google.com/p/pihipi
> blok ~http://www.tagarga.com/blok
Ahhh... I missed the extra parameters for preg_match.... I was
looking at what was returned. Silly me. Thanks.
Navigation:
[Reply to this message]
|