Skip to main content

Posts

Showing posts with the label echo

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.

How can I check if an array contains a specific value in php?

I have an array of data created by a form that and I would like find out if it contains a specific value and let the user know that it is there. This is my array: Array ( [0] => kitchen [1] => bedroom [2] => living_room [3] => dining_room) and I would like do something like: if(Array contains 'kitchen') {echo 'this array contains kitchen';} What is the best way to do the above???