Why do I want to sum the text in an array in PHP but the strlen function can only be executed according to the order of my array. Eg:
$array = ['One', 'Two', 'Three'];
strlen result is
3 3 5
What i want is 11
. Is there any solution?
try this
$array = ['One', 'Two', 'Three'];
echo $total_str_length = array_sum(array_map('strlen', $array));
O/P: 11
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.