Ask a Question related to PHP Development, Design and Development.
-
Carl Furst #1
RE: [PHP] find string
Isn't there an in_array function you can use?
If (in_array($action, array(a1,a2,a3,a4)) {
// do something
}
else {
// do something else
}
Carl.
-----Original Message-----
From: andu [mailto:php@archeopterix.com]
Sent: Sunday, August 10, 2003 7:15 PM
To: [email]php-general@lists.php.net[/email]
Subject: [PHP] find string
Here's the problem I have:
I have $action which can be anyone of a1, a2, a3, a4.
I tried
if ($action!='a1' || $action!='a3') //tried == also
{
//do stuff
}
else
{
//do other stuff
}
Problem is that if() only seems to take one option so my construct
above doesn't work.
What function can I use to do something like:
if ($action is among the items of 'a2,a4') kind of construct?
I tried strpos('a1a2a3',$action) but with the same results.
TIA
--
Regards, Andu Novac
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Carl Furst Guest
-
can't find string with quotes
I'm trying to search for a string that contains quotes and my find statement keeps returning 0 even though I know the string exists in my... -
How to find second occurence of a string?
Hi i am using the find function which will search the first occurence of a string. but how we can find the second or third ...occurence of the... -
Find and cut string
Hi, I'm new to PHP, so please bear with me! =) Is there a nice little function to find a string between to html-tags? I.e. let's say I have a... -
find in string
How can i count the number of times a string appears within another string. Thanks a... -
find string between files
Hi all, how can I search for a specific string inside a directory (between files) ? Thanks for your help -
Andu #2
Re: [PHP] find string
On Sun, 10 Aug 2003 19:27:12 -0400
"Carl Furst" <carl@vote.com> wrote:
Thanks Carl, if there is no string function for the job I'll have to> Isn't there an in_array function you can use?
>
> If (in_array($action, array(a1,a2,a3,a4)) {
> // do something
> }
> else {
> // do something else
> }
>
>
> Carl.
use the array.
>
> -----Original Message-----
> From: andu [mailto:php@archeopterix.com]
> Sent: Sunday, August 10, 2003 7:15 PM
> To: [email]php-general@lists.php.net[/email]
> Subject: [PHP] find string
>
> Here's the problem I have:
> I have $action which can be anyone of a1, a2, a3, a4.
> I tried
>
> if ($action!='a1' || $action!='a3') //tried == also
> {
> //do stuff
> }
> else
> {
> //do other stuff
> }
>
> Problem is that if() only seems to take one option so my construct
> above doesn't work.
> What function can I use to do something like:
> if ($action is among the items of 'a2,a4') kind of construct?
> I tried strpos('a1a2a3',$action) but with the same results.
> TIA
>
> --
> Regards, Andu Novac
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--
Regards, Andu Novac
Andu Guest
-
David Nicholson #3
Re: [PHP] find string
Hello,
This is a reply to an e-mail that you wrote on Mon, 11 Aug 2003 at
00:25, lines prefixed by '>' were originally written by you.
Make sure that your string values are in quotes or PHP will belooking> Isn't there an in_array function you can use?
> If (in_array($action, array(a1,a2,a3,a4)) {
> // do something
> else {
> // do something else
> Carl.
for constants with those names, i.e. array('a1','a2','a3','a4')
David.
--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: [url]http://www.phpmachine.com/[/url]
Free PHP error handling script: [url]www.phpmachine.com/error-handler/[/url]
Professional Web Development by David Nicholson
[url]http://www.djnicholson.com/[/url]
QuizSender.com - How well do your friends actually know you?
[url]http://www.quizsender.com/[/url]
David Nicholson Guest
-
Andu #4
Re: [PHP] find string
On Mon, 11 Aug 2003 10:00:57 +1000 (EST)
<daniel@electroteque.org> wrote:
Action is exactly what you imagine and at some point in the scrip I use> what exactly is action ?
>
> i usually use a action setup like follows
>
> ?action=update
>
> switch ($_GET['action']) {
> case 'update':
> //do stuff here
> break;
> case 'insert':
> //do stuff here
> break;
>
> }
>
> very clean
what you suggest, why I didn't do it here is because I didn't have
enough coffee today ;-). Nevertheless the previously suggested solution
using in_array() seems cleaner in this case.
>>> > Here's the problem I have:
> > I have $action which can be anyone of a1, a2, a3, a4.
> > I tried
> >
> > if ($action!='a1' || $action!='a3') //tried == also
> > {
> > //do stuff
> > }
> > else
> > {
> > //do other stuff
> > }
> >
> > Problem is that if() only seems to take one option so my construct
> > above doesn't work.
> > What function can I use to do something like:
> > if ($action is among the items of 'a2,a4') kind of construct?
> > I tried strpos('a1a2a3',$action) but with the same results.
> > TIA
> >
> > --
> > Regards, Andu Novac
> >
> > --
> > PHP General Mailing List ([url]http://www.php.net/[/url])
> > To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
>
>
>
> --
> PHP General Mailing List ([url]http://www.php.net/[/url])
> To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
>
>
>
--
Regards, Andu Novac
Andu Guest



Reply With Quote

