简体   繁体   中英

PHP: How to get characters length of specific associative array key value

i need get characters length of "fsdfsdf". Who can help me? :)

$array = array(
    'Firstname' => $wpdb->escape($_REQUEST['Firstname']),
    'Lastname' => $wpdb->escape($_REQUEST['Lastname']),
    'Phone' => $wpdb->escape($_REQUEST['Phone']),
    'Email' => $wpdb->escape($_REQUEST['Email'])
);

print_r($array):

Array
(
    [Firstname] => fsdfsdf
    [Lastname] => 
    [Phone] => 
    [Email] =>
)
$char_length = strlen($array['Firstname']);

Try this,

$length =   strlen($array[Firstname]);
echo $length;

希望对您有帮助,

 echo strlen(trim($array['Firstname']));

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