Warning: strlen() expects parameter 1 to be string, array given in symfony 4
How to solve this? Please Help.
Warning: strlen() expects parameter 1 to be string, array given in symfony 4
How to solve this? Please Help.
The function strlen() is used to retrieve the length of a string. So you should pass a string as a parameter not an array. The error is pretty much self explanatory.
Summary and useful :
count() : size of the an array
strlen() : length of string
Several useful and relevant links:
Warning: strlen() expects parameter 1 to be string, array given in file... in line
Warning: strlen() expects parameter 1
Warning: strlen() expects parameter 1 to be string, array given
http://php.net/manual/en/function.strlen.php
Calculate the length of the string of elements of a one-dimensional array:
<?php
$array=array("Hello","How are you","Are you good?","Yeah");
//This is not correct! : strlen($array);
foreach($array as $item)
{
$length=strlen($item);
echo $item." ( $length )\n";
}
?>
Output :
Hello ( 5 )
How are you ( 11 )
Are you good? ( 13 )
Yeah ( 4 )
The strlen($array)
will occur a warning.
PHP Warning: strlen() expects parameter 1 to be string, array given in ... on line ...