James Bachini

list to php array list2phparray

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>’;
}

?>


Get The Blockchain Sector Newsletter, binge the YouTube channel and connect with me on Twitter

The Blockchain Sector newsletter goes out a few times a month when there is breaking news or interesting developments to discuss. All the content I produce is free, if you’d like to help please share this content on social media.

Thank you.

James Bachini

Disclaimer: Not a financial advisor, not financial advice. The content I create is to document my journey and for educational and entertainment purposes only. It is not under any circumstances investment advice. I am not an investment or trading professional and am learning myself while still making plenty of mistakes along the way. Any code published is experimental and not production ready to be used for financial transactions. Do your own research and do not play with funds you do not want to lose.


Posted

in

by

Tags: