0

Put variable values inside an array

Can someone help me? I’m creating a program with php and i would like to put the values of an variable called $error and put in an array

16th May 2019, 1:33 AM
Matheus Rodrigues
Matheus Rodrigues - avatar
4 ответов
+ 4
Maybe this way: <?php // Create the array. $error = []; if (...test fails...) { // Add elements to the array. $error[] = 'Error message ...'; } // Walk through the array and print it. foreach ($error as $err) { echo $err . PHP_EOL; } ?>
16th May 2019, 3:13 PM
Johann
Johann - avatar
+ 1
Thanks Johann Ditrich i got it !
27th May 2019, 12:29 AM
Matheus Rodrigues
Matheus Rodrigues - avatar
+ 1
You're welcome
27th May 2019, 3:15 AM
Johann
Johann - avatar
16th May 2019, 2:02 AM
Matheus Rodrigues
Matheus Rodrigues - avatar