Ich habe eine PHP-while-Schleife wie folgt:Output Array in einem bestimmten Format
$tmp = array();
//loop for category dropdown menu
while($r = $stmt->fetch())
{
$start_time = $r['consultation_start'];
$end_time = $r['consultation_end'];
$holiday = htmlspecialchars($r['consultation_holidays']);
$tmp[] =sprintf(" $holiday ,");
}
//concatenate loop strings
foreach($tmp as $output)
{
$holidays = implode('', $tmp);
$consultholidays = substr_replace($holidays ,"",-1);
}
echo $consultholidays;
$stmt->closeCursor();
}
Ich brauche die Ausgabe im Format zu erhalten:
[Sunday], [Wednesday]
ich versuchte, mit:
$tmp[] =sprintf(" [$holiday] ,");
Aber es gibt Ausgabe als:
[Sunday,Wednesday]
Wie kann ich das Ausgabeformat wie:
[Sunday], [Wednesday]
Sorry, ich bin neu in PHP und learning..so bitte Fehler verzeihen.
Was enthält '$ holiday'? Veröffentlichen Sie seinen Wert. – mega6382
@ mega6382 $ holiday enthält Sonntag, Mittwoch – Pamela
this '[Sonntag, Mittwoch]' nicht definieren, ist es String oder ein Array, so sei spezifisch. – User97798