PHP how to split an array in variables -
hi need help! i've starting learn php week ago. have form post text field contact, need split array in variables put in email. code
$field = $_post['input']; if ( isset( $field ) === true){ foreach ($field $key => $value) { echo '<pre>' , print_r( $value ) , '</pre>'; //to list array } $to = $mail; $sbj = "thanks register $site"; ..//some headers mail($to,sbj,$headers) }
and form
<form action="upload.php" method="post"> <input type="text" name="input[]"> <input type="text" name="input[]"> <input type="text" name="input[]"> <input type="submit" value="invia"> </form>
any suggestion retrive variables on array include on mail?
@john has given right procedure . can use procedure using array_push() function eg:
$field = $_post['input']; $info = array(); foreach ($field $key => $value) { array_push($info,$value); } // echo implode(",",$info); $to = $mail; $sbj = "thanks register $site"; $body = implode(",",$info); ..//some headers mail($to,sbj,$body,$headers)
Comments
Post a Comment