-5

this is my input filed which I'm using

HTML input field

This is how I am print my variable

print values

getting this error

Array ( [0] => Notice: Array to string conversion in C:\xampp\htdocs\attendance-system\view-all-latecomers.php on line 162 Array )

Any Solution please helped me. Thanks

Umer Best
  • 9
  • 1
  • 8
  • 4
    Possible duplicate of [How to solve PHP error 'Notice: Array to string conversion in...'](https://stackoverflow.com/questions/20017409/how-to-solve-php-error-notice-array-to-string-conversion-in) – Jigar Shah Sep 15 '17 at 08:05
  • 1
    Remove the images and copy paste the code instead – Andreas Sep 15 '17 at 08:06

1 Answers1

0

When you add [] to the end of an input name, that causes all the values of those inputs to be put into an array in PHP. So $_POST['checked_id'] is an array, not a string. Then when you do:

value="<?= $_POST['checked_id'] ?>"

you're trying to echo the entire array into that one input. You can't echo an array, so you get that warning.

If this is part of a loop, you need to index the array

for ($i = 0; $i < count($_POST['checked_id']); $i++) { ?>
    ...
    <input type="hidden" name="checked_id[]" value="<?=$_POST['checked_id'][$i]?>">
    ...
    <?php
}
Barmar
  • 741,623
  • 53
  • 500
  • 612