Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

foreach loop not working in php

<?php
$songs = $_POST["songs"];
//$songs = Array("one","two","three");
foreach ($songs as $song) 
{
   $songStr = test_input($song);
   $songsOut .= "<li>$songStr</li>";
};

$songList = "Songs: <ol> $songsOut </ol> 
";
echo $songList;

function test_input($data)
{
   $data = trim($data);
   $data = stripslashes($data);
   $data = htmlspecialchars($data);
   return $data;
}

?>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #foreach #loop #working #php
ADD COMMENT
Topic
Name
7+5 =