← CodePrimer
PHP
Beginner
Forms
Read checkbox array in PHP
How do I read skills[] from a form?
Cast POST array safely.
<?php
$skills = $_POST['skills'] ?? [];
if (! is_array($skills)) {
$skills = [];
}
$skills = array_map('strval', $skills);
Notes
Always verify is_array before looping.
Keywords: checkbox · array · $_POST
Related
PHP
Embed PHP inside HTML
How do I mix PHP and HTML?
PHP
PHP comments
How do I write comments in PHP?
PHP
PHP variable rules
What are the rules for PHP variables?
PHP
echo vs print
Should I use echo or print?
PHP
PHP scalar data types
What data types does PHP have?
JavaScript
Live input event
How do I react as the user types?