Can't seem to get rtrim to work and I don't understand why:
$array = array("top" => array("one" => "inner one", "two" => "inner two"));
foreach (array_keys($array) as $key) {
$form[$key] = array();
$sql = "INSERT INTO $key SET ";
foreach (array_keys($array[$key]) as $field) {
array_push($form[$key], $field);
$sql .= $field." = '".$array[$key][$field]."',";
}
}
rtrim($sql,',');
$sql .= ";";
Why would this not get rid of the last comma?
it keeps printing out this:
INSERT INTO top SET one = 'inner one',two = 'inner two',;