Re: Reg Expression Search
| From: | Joe Stump | Date: | Tue, 17 Oct 2000 07:52:22 +0000 |
| Subject: | Re: Reg Expression Search | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-20567@lists.php.net to get a copy of this message | ||
Yep - to do that just do something like this.
$last = (sizeof($foo) - 1);
--Joe
ps I like contributing now that I know the ins and outs ;o)
On Tue, Oct 17, 2000 at 05:22:35PM +0930, Scott Mebberson wrote:
> Hi Joe, thanks man. You answer a lot of question in this board. Congrats!!
>
> Now, I can do this. But to get the last one I would need to find the last
> "number" in the array and then that is my answer?!?! Correct??
>
> Thanks.
>
> scott.
>
> Scott Mebberson
> Interactive Media Designer
>
> phone | +61 8 8346 1622
> fax | +61 8 8346 1722
> email | scott@redbluedesign.com
> web | www.redbluedesign.com
>
> -----Original Message-----
> From: jstump@professorx.care2.com [mailto:jstump@professorx.care2.com]On
> Behalf Of Joe Stump
> Sent: Tuesday, 17 October 2000 5:16 PM
> To: Scott Mebberson
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Reg Expression Search
>
> If you just want the string up until the first \ then do this:
>
> $junk = 'C:\foo\bar\file.txt';
> $foo = explode('\',$junk);
>
> // should return C:
> echo $foo[0];
>
> // should return foo
> echo $foo[1];
>
> // should return bar
> echo $foo[2];
>
> // should return file.txt
> echo $foo[3];
>
> --Joe
>
>
> On Tue, Oct 17, 2000 at 05:14:28PM +0930, Scott Mebberson wrote:
> > Hi Guys,
> >
> > I have real problems with reg exps. I hate them.
> >
> > I need to do a search on string that will look like this "C:\temp\bg.gif"
> > and I want to take from the end of string up until the first backslash.
> The
> > var $realVal contains the string. So I can either take it
> from --\[*].gif--
> > or --\[*].jpg--
> >
> > thanks for all help
> >
> > scott.
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> /*****************************\
> * Joe Stump *
> * www.Care2.com *
> * Office: 650.328.0198 *
> * Extension: 122 *
> \*****************************/
> http://www.miester.org/Joe/Stump/Joe_Stump_resume.html
>
> -----BEGIN GEEK CODE BLOCK-----
> Version: 3.12
> GB/E/IT d- s++:++ a? C++++ UL++$ P+ L+++$ E----! W+++$
> N+@ o? K? w---! O-@ M+@ V-! P(++) PE(+) Y+@ PGP+++@ t+@
> 5? R-! tv@ b+ DI++@ D(++++) G++@ e+@ h@ r+! z(+++++**)!
> ------END GEEK CODE BLOCK------
>
/*****************************\
* Joe Stump *
* www.Care2.com *
* Office: 650.328.0198 *
* Extension: 122 *
\*****************************/
http://www.miester.org/Joe/Stump/Joe_Stump_resume.html
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GB/E/IT d- s++:++ a? C++++ UL++$ P+ L+++$ E----! W+++$
N+@ o? K? w---! O-@ M+@ V-! P(++) PE(+) Y+@ PGP+++@ t+@
5? R-! tv@ b+ DI++@ D(++++) G++@ e+@ h@ r+! z(+++++**)!
------END GEEK CODE BLOCK------