PHP:如何获取特定关联数组键值的字符长度

时间:2013-11-03 09:38:08

标签: php arrays

我需要获取字符长度“sdfsdf”。谁能帮我? :)

$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
(
    [Firstname] => fsdfsdf
    [Lastname] => 
    [Phone] => 
    [Email] =>
)

3 个答案:

答案 0 :(得分:3)

$char_length = strlen($array['Firstname']);

答案 1 :(得分:1)

试试这个,

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

答案 2 :(得分:1)

希望它可以帮到你,

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