My php knowledge is not enough to deal with such a complex array. I am geting it in my Zend Framework 2.3 app while form validation, and want to list all errors, not show each in below input field.
This is an array that I got
Array (
[email] => Array (
[isEmpty] => Value is required and can't be empty
[someElse] => Some other message
)
[subject] => Array (
[stringLengthTooLong] => The input is more than 128 characters long
)
[content] => Array (
[isEmpty] => Value is required and can't be empty
)
)
and this is what i have tried so far
i know there is something like Key() but is this what i should be using?
I want to get an output
email - Value is required and...
email - Some other message
Subject - THe input is more than...
content - Value is ..
So far i have tried
if(isset($errorsMessages)) {
while (current($errorsMessages)) {
echo key($errorsMessages);
next($errorsMessages);
}
}
it works i am getting list email, subject, content. But then i want to read certain sub-arrays. I have tryied
if(isset($errorsMessages)) {
while ($fruit_name = current($errorsMessages)) {
echo key($errorsMessages);
foreach ($errorsMessages as $i) {
foreach($i as $j) {
echo '<br ./>' . ' - ' . $j;
}
}
next($errorsMessages);
}
}
but it is a totall mess, i am getting output
email
- Value is required and can't be empty
- The input is more than 128 characters long
- Value is required and can't be empty