php - Print_r errors without Array -


i coding website , have stumbled across problem not solve utilizing popular search engines.

question: how print_r arrays without displaying unnecessary text? example: 'array()' before displaying error.

example: php config code

if(isset($submit)) { $errors = array();  if( $password == $username ) {     $errors[] = 'same username , pass'; } if( $userlen < 8 ) {     $errors[] = 'username must atleast 8 characters.'; } if( $userlen > 32 ) {     $errors[] = 'username must contain 32 characters'; }  if (count($errors) == 0) {     require 'db/connect.php';     $insertuser = "insert users (username, password) values ('$username','$password')";     mysql_query($insertuser); } }  ?> 

code call error array:

<div id='errs'>  <?php  print_r($errors); ?>  </div> 

this example of result: ' array ( [0] => username must atleast 8 characters. ) ' want read 'username must atleast 8 characters'.

thanks in advanced! -and sorry noob question.

  1. stop using mysql_* it's deprecated.
  2. prepare / sanitize statements.
  3. use mysqli_*

    <?php if(!empty($errors)) {?>  <div id='errs'>  <?php  foreach($errors $error) { echo $error; } ?>  </div>  <?php } else {} ?> 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -