Jump to content

strtolower function - syntax needed


murfitUK

Recommended Posts

I'm sure some kind soul will help.I'm putting the results of a search into a table but I am trying to use the strtolower function without success - getting confused with round brackets, curly brackets, square brackets, single quotes and double quotes etc!This is a line of the code so far:print "\n\t<td>{$row["CODE"]}</td>" . "\n\t<td>{$row["TR"]}</td>" . etcI would like to use strtolower function so that the CODE field is printed in the table in lower case letters but just can't manage it.Could someone please let me know what the syntax should be. Thanks for your help.

Link to comment
Share on other sites

Thanks for the quick response. I have tried your suggestion but it doesn't work. I get this error message:Parse error: parse error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\Abyss Web Server\htdocs\newweb\results.php on line 91and line 91 is:print "\n\t<td>{strtolower($row["CODE"])}</td>" . (I've copied and pasted to make sure its correct.)The field CODE is type varchar(255).Thanks for your help.

Link to comment
Share on other sites

Thanks for the quick response.  I have tried your suggestion but it doesn't work.  I get this error message:Parse error: parse error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\Abyss Web Server\htdocs\newweb\results.php on line 91and line 91 is:print "\n\t<td>{strtolower($row["CODE"])}</td>" . (I've copied and pasted to make sure its correct.)The field CODE is type varchar(255).Thanks for your help.

whoops sorry it should be this
print "\n\t<td>{strtolower($row['CODE'])}</td>" .

You can't use double quotes inside double quotes without escaping htem. in this case iwas just easier to use single quotes around CODE - 'CODE'

Link to comment
Share on other sites

If you're making a function call, you have to have it outside the string altogether. String interpolation only happens with variables and constants:

print "\n\t<td>" . strtolower($row['CODE']) . "</td>"

Link to comment
Share on other sites

Ah double quotes and single quotes. I knew it had something to do with.My solution (until I tried your suggestions) was to pull out the field first, modify it and then stick it into the table:$codelc=strtolower{$row["CODE"]};...print "\n\t<td>{$codelc}</td>" ....or something like that anyway. But now I know the correct way I shall go and change it again.Thanks folks.

Link to comment
Share on other sites

$codelc=strtolower{$row["CODE"]};...print "\n\t<td>{$codelc}</td>" ....
That would work fine, but the syntax is incorrect for calling a function. A function's list of parameters is inside parentheses, not curly brackets:
$codelc=strtolower($row["CODE"]);...print "\n\t<td>{$codelc}</td>" ....

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...