php arrays + function

-1

Good,

I have a question ..

I'm using array errors [] in array. I created a function that simply shows me the error design + message

 warning_alert('Caracteres do tituto superiores a 4.');

 function warning_alert($text) {
  echo "
  <div class='alert warning'>
  <span class='closebtn'>&times;</span>  
  <strong><i class='fas fa-exclamation-circle'></i></strong> $text
  </div>"; 
 }

Here is where it says the ERROR message. But it is not working ...

 $errors[] = warning_alert('Caracteres do tituto superiores a 4.');

This is the error message :

 if(strlen($ads_title) < 4 && strlen($ads_title) > 35) {

  $errors[] = warning_alert('Caracteres do tituto superiores a 4.'); 

 }

Array errors works this way.

          if(!empty($errors)) {  

              echo display_errors($errors);

          } else {

             if(move_uploaded_file($file_tmp, $file_destination)) {}

Any ideas?

    
asked by anonymous 01.04.2018 / 16:07

1 answer

0

Hello!

Try to use return instead of echo, because you want it to store in the array, but the function has no return.

    
09.04.2018 / 18:51