Re: complex control structure- please help
| From: | Chris | Date: | Wed, 21 Jun 2006 02:02:05 +0000 |
| Subject: | Re: complex control structure- please help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-238448@lists.php.net to get a copy of this message | ||
IG wrote:
Hi all,
This may not be complex at all- maybe my head is just screwed up this afternoon!
I am looping through arrays all at one time for the following-
$filter_subject
$filter_body
$filter_email
$filter_subject_like
$filter_body_like
$filter_email_like
Examples of the following could be-
$filter_subject[0] = "This is the subject";
$filter_body[0] = "This is the body";
$filter_email[0] = "email@email.com";
$filter_subject_like[0] = "";
$filter_body_like[0] = "";
$filter_email_like[0] = "";
$filter_subject[1] = "";
$filter_body[1] = "";
$filter_email[1] = "";
$filter_subject_like[1] = "lots of nice things";
$filter_body_like[1] = "horrible body text";
$filter_email_like[1] = "email@email.com";
$filter_subject[2] = "";
$filter_body[2] = "";
$filter_email[2] = "";
$filter_subject_like[2] = "Lots of nice things";
$filter_body_like[2] = "";
$filter_email_like[2] = "";
$filter_subject[3] = "";
$filter_body[3] = "This is the complete body";
$filter_email[3] = "";
$filter_subject_like[3] = "Part of the subject";
$filter_body_like[3] = "";
$filter_email_like[3] = "";
I then run something like the following on the variables $subject, $body, $email, $subject_like, $body_like and $email_like....
....
for($e=0;$e<count($filter_subject);$e++) {
...
if($subject == $filter_subject[$e]) {$found_subject = 1;} // Subject has been found
if($body == $filter_body[$e]) {$found_body = 1;} // Body has been found
if($email == $filter_email[$e]) {$found_email = 1;} // Email has been found
if(strpos($subject_like, $filter_subject_like[$e])) {$found_subject_like = 1;} // Subject(like) has been found
if(strpos($body_like, $filter_body_like[$e])) {$found_body_like = 1;} // Body(like) has been found
if(strpos($email_like, $filter_email_like[$e])) {$found_email_like = 1;} // Email(like) has been found
...
}
What I want to do is work out if (from the above examples) the following (not written in php by the way, just in kind of english)
example 0 -
if - ($subject == "This is the subject" AND $body == "This is the body" AND $email == "email@email.com") THEN DO THE FOLLOWING....
example 1 -
if - ($subject == "lots of nice things" AND $body_like contains "horrible body text" AND $email contains "email@email.com") THEN DO THE FOLLOWING....
example 2
if - ($subject contains "Lots of nice things") THEN DO THE FOLLOWING....
example 3
if - ($body == "This is the complete body" AND $subject contains "Part of the subject") THEN DO THE FOLLOWING....
How can I organise a control structure so that I can do the above? My brain is hurting and I could do with some thoughts from you guys!
You're most of the way there.
convert it to php code and you're basically done:
if ($body == '...') {
echo "Body is $body\n";
}
and so on.
I don't see the problem here ?
--
Postgresql & php tutorials
http://www.designmagick.com/