list to php array list2phparray

0
193

Code below for a script to take a list and turn it into an array. Comes in pretty useful.

<?php

if ($_POST[‘list’]) {
$splist = explode(“\n”, $_POST[‘list’]);
$out = ‘$x = array(‘;
foreach ($splist as $line) {
$out = $out.”‘$line’, “;
}
$out = substr($out,0,-1);
$out = substr($out,0,-1);
$out = $out.’);’;

echo $out;

} else {
echo ‘<html><body>’;
echo ‘<h1>List 2 php array</h1>’;
echo ‘<form action=”list2phparray.php” method=”post”>
<textarea cols=”100″ rows=”30″ name=”list”></textarea>
<input name=”Submit” type=”submit” value=”Submit” />
</form>
</body></html>’;
}

?>

SHARE
Previous articleProsper202 Hacks and Modifications
Next articleCPA Tips

LEAVE A REPLY

Please enter your comment!
Please enter your name here