Welcome Guest, Not a member yet? Register   Sign In
Ternary usage
#1

[eluser]Todlerone[/eluser]
Hello everyone and TY in advance. I'm trying to use a ternary condition to establish some output in a view. However, I keep getting errors. I have three possible prefixes to a word. What I'm trying to do is determine if each one is set in the database then append them together with a space between them. Example: Lt Sup Occipital or Lt Ant Occipital.

My variables are sagittal, axial or coronal. Here is a sample of what I have tried in my view.

Code:
<?php $location = ($plan['sagittal']) ? $plan['sagittal']." " : //nothing ?>
<?php $location .= ($plan['axial']) ? $plan['axial']." " : //nothing ?>
<?php $location .= ($plan['coronal']) ? $plan['coronal']." " : //nothing ?>
....then echo out $location

TY for any help


Messages In This Thread
Ternary usage - by El Forum - 01-13-2011, 03:38 PM
Ternary usage - by El Forum - 01-13-2011, 03:59 PM
Ternary usage - by El Forum - 01-13-2011, 05:21 PM



Theme © iAndrew 2016 - Forum software by © MyBB