array_chunk in email body php -


i have form user can click on button add many partecipants needs. every partecipant have 4 fields. fields automatically added script when click on button add partecipants. fields created [data] have in php file send email:

if(isset($_request['data'])){ $postdata = $_request['data']; }  if( isset($postdata) ) {     $altri = implode('<hr>', array_chunk($postdata, 4, true));  } else {     $altri = 'non sono stati aggiunti altri partecipati questa richiesta'; } 

then in $body try print result as:

$body = <<<eod <strong>altri partecipanti:</strong><br>$altri<br>  // php email sender mail($to, $sub, $body, $headers); 

as can see try group , separate 4 fields in email output obtain like:

  • field_1_participant_1
  • field_2_participant_1
  • field_3_participant_1
  • field_4_participant_1

separator

  • field_1_participant_2
  • field_2_participant_2
  • field_3_participant_2
  • field_4_participant_2

... etc...

i'm not able let work intended , got error message "array string conversion"

how write code obtain it? in advance.

think array_chunk does. produces array of arrays, eg

[ ['f1p1', 'f2p1', 'f3p1', 'f4p1'], ['f1p2', 'f2p2', 'f3p2', 'f4p2'] ] 

try using array_map convert inner arrays strings. example

$altri = implode('<hr>', array_map(function($list) {     return '<ul><li>' . implode('</li><li>', $list) . '</li></ul>'; }, array_chunk($postdata, 4))); 

this produces

<ul><li>f1p1</li><li>f2p1</li><li>f3p1</li><li>f4p1</li></ul><hr><ul><li>f1p2</li><li>f2p2</li><li>f3p2</li><li>f4p2</li></ul> 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -