在發布 Wordpress 重力表單插件的“輸入”資料時,我正在使用 function.php 代碼將所有字符轉換為大寫。
add_action('gform_pre_submission_1', 'capitalize_fields_1');
function capitalize_fields_1($form){
// add all the field IDs you want to capitalize, to this array
$fields_to_cap = array('input_1');
foreach ($fields_to_cap as $each) {
// for each field, convert the submitted value to uppercase and assign back to the POST variable
// the rgpost function strips slashes
$_POST[$each] = strtoupper(rgpost($each));
}
// return the form, even though we did not modify it
return $form;
}
但是,我使用的是土耳其語,并且有一個 UTF-8 之外的字符。轉換時小寫字母“i”變成字母“I”。這兩個字符的含義不同。我想將小寫字母“i”轉換為字母“I”。
我找到了這個程序的 php 代碼,但我無法將它改編為 function.php 檔案。
function mb_strtoupper_tr($metin){
$metin=str_replace('i', '?', $metin);
誰能幫助我如何適應這一點或實施更有效的方法?
uj5u.com熱心網友回復:
add_action('gform_pre_submission_1', 'capitalize_fields_1');
function capitalize_fields_1($form){
// add all the field IDs you want to capitalize, to this array
$fields_to_cap = array('input_1');
foreach ($fields_to_cap as $each) {
// for each field, convert the submitted value to uppercase and assign back to the POST variable
// the rgpost function strips slashes
$_POST[$each] = strtoupper(str_replace('i', '?', rgpost($each)));
}
// return the form, even though we did not modify it
return $form;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/411695.html
標籤:
