I'm looking to change the the article a/an in a webpage based on a parameter passed via the URL. So for example, I've got mywebpage.com/?page&qry=dog as the URL, so I would want any a/an articles to be "a" dog (vs "an" aardvark were that the qry). I'm trying to use the code below, however I'm getting a parse error any time I try to load the page.
<?php in_array(substr($_GET['qry'],0,1), array('a','e','i','o','u')) ? 'an' 'a'; ?>
If also tried an IF/ELSE statement, which lead to the same result.
<?php if(in_array(substr($_GET['qry'],0,1), array('a','e','i','o','u'))):'an':'a'; ?>
I'm sure I'm missing something simple, most likely related to my attempt to insert this snippet amongst standard HTML text; can anyone spot my error(s)?
This is the error I get back:
Parse error: parse error in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\testsite\html\page.html.php on line 117
Thank you!
<?php if(in_array(substr($_GET['qry'],0,1), array('a','e','i','o','u')))?'an':'a'; ?>try that. Not sure if it will work though.<?php in_array(substr($_GET['qry'],0,1), array('a','e','i','o','u'))?'an':'a'; ?>removing theif(). Try that. Ternaries don't useif.