![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the length of longest string in a PHP array
The array_map function can be used to get the length and the max function can be used to get the length of the longest string.
Below is a code sample for the same −
$max_len = max(array_map('strlen', $array));
Example
$array = array("a", "Ab", "abcd", "abcdfegh", "achn"); $max_len = max(array_map('strlen', $array)); echo $max_len;
Output
This will produce the following output −
8
Advertisements