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
4 Respostas
+ 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;
}
?>
+ 1
Thanks Johann Ditrich i got it !
+ 1
You're welcome