I am self-learning php and I want to ask if am I reading this part of code correctly?
If
powers is not empty, than make array
from values
,
also each power
will act like power_id
. But $values[]
is same as array_pust()
? And sprintf('(%d, %d)'
will put decimal numbers to character_id and power?
$character_id = mysql_insert_id($db);
if(!empty($_POST['powers'])) {
$values = array();
foreach ($_POST['powers'] as $power_id) {
$values[] = sprintf('(%d, %d)', $character_id, $power_id);
}