简体   繁体   中英

how to change all input field values into upper case

I have set of PHP fields.

Before sending the values into a query, I want to change the letters to upper case.

Is there a way to do something like:

$cust_name   = "john";
$cust_gender = "male";

lower_upper_conversion($_);

so that now john has changed to JOHN, and male has changed to MALE?

After this function is crossed or passed, all variables need to change into upper case.

I do not want normal solution where I have to call for each field:

$cust_name   = "john";
$cust_gender = "male";

lower_upper_conversion($cust_name);
lower_upper_conversion($cust_gender);
JOHN , MALE, 
$_POST = array_map("strtoupper", $_POST);

This will make all values in the POSTed form upper case.

There is no general method to apply a function to all variables in scope. They need to be in an array first.

You want to use strtoupper

$cust_name = "john";
echo strtoupper($cust_name); // Outputs JOHN

Is this what you are after? http://php.net/strtoupper

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM