If you want to textarea lines convert to array using php then check this demo code which help you.
Important thing that your textarea must need new line. In this code i added
for new line for better understand
$text = "Name:Jay <br/> Email:jayviru@demo.com <br/> Contact:9876541230"; $array_data = explode('<br/>', $text); $final_data = array(); foreach ($array_data as $data){ $format_data = explode(':',$data); $final_data[trim($format_data[0])] = trim($format_data[1]); } echo "<pre>"; print_r($final_data);
Then output is :
Array ( [Name] => Jay [Email] => jayviru@demo.com [Contact] => 9876541230 )
And if your text area value get using php variable then simple use this code
<?php $text = $_POST['filed_value']; $array_data = explode(PHP_EOL, $text); $final_data = array(); foreach ($array_data as $data){ $format_data = explode(':',$data); $final_data[trim($format_data[0])] = trim($format_data[1]); } echo "<pre>"; print_r($final_data);
This is get same value, if you face any problem then please inform me. I will try to help you