php - Sending delimited from textarea to mysql. Column by "," and row by "\n" -


i need user able enter data textarea in following format.

name,email@email.com

name,email@email.com

name,email@email.com

the information sent mysql database. issue want place proper name first column , proper email second column. then, when encounter line break start new row.

can this? thanks!

as others have said can use explode results array however, problem approach there no guarantee user enter information in correct order.

what this. it's still not fool proof (and using separate inputs better) it's better.

<?php  $textareastring = $_post['textareaname'];  $array = explode("\n",$textareastring );  foreach($array $value) {  $data = explode(',',$value);  if (strpos($data[1], '@'))  {    $name = $data[0];    $email = $data[1];  }else{    $name = $data[1];    $email = $data[0];  } } ?> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -