|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Dynamic IF statement
I have a very long line of code in the following example statement
if (archive == "Y") condition ="blabalba"; else condition ="qwerqwerqw"; if (condition) { . . .CODE HERE . . } What i want to do here is, causing 'condition' to be evaluated to a different thing based on 'archive'. Is this possible in PHP?
__________________
Beginner |
|
#2
|
|||
|
|||
|
Re: Dynamic IF statement
Quote:
The statement evaluating $archive doesn't seem to be too long. I see two branches, an if and an else. Am I missing something. If you just want to shorten this if/else, then you can try this syntax: $condition = $archive=="Y" ? "blabalba" : "qwerqwerqw"; Your if/else is now condensed to one line. Hope this helps, -- Wil Moore III www.wilmoore.com |
|
#3
|
|||
|
|||
|
Yeah, I know, ...thanks...but
What I really meant was $condition being of the following form $condition = ($datenow < $enddate) && ($puboptions == "A" || $puboptions == "M") ..... not just plain 'qwerqewr'...etc NOw replace the $condition in if with the above. I thought i tried it but it doesn't work. |
|
#4
|
|||
|
|||
|
Your question really wasn't all that detailed in the first post...
Your second post was not much help either. I'm not sure I'll be able to help you further until you can rethink your post and submit it in a form that is clear. However, if I were to guess what you meant, I'd say that you may want to try replacing && with and. Sorry 'bout that,
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Programming Tools > Dynamic IF statement |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|