我希望能够使用函数向称为播放列表的数组添加新值(是必需的).但每次我输入另一个值时,它都会替换旧的值,而不是仅添加数组的末尾.哪里不对?
原文链接:https://www.f2er.com/php/138543.html<?PHP $playlist = array("Be more.mp3","Drift Away.mp3","Panda Sneeze.mp3"); function add_songs_playlist() { global $playlist; ?> <form method = "post"> <input type = "text" name = "name1"/> <input type = "submit" name = "submit1"/> </form> <?PHP if (isset($_POST['submit1'])) { $newsong = $_POST['name1']; array_push($playlist,$newsong); } } add_songs_playlist(); foreach ($playlist as $value) { echo $value."<br>"; }