Jump to content
Sign in to follow this  
Illasera

A loop within mail

Recommended Posts

Hey all, I am sending mail via ZendMail, And i wish to know how to list of products in the mail body,Consider the following example, I have an array of string written in php, And i wish to display them in my mail body,How do i achieve that? I can`t call php functions/operators within the mail, What do i need to do, Here is an example :

// Mail php array.<?php$mail_Products = array("Apple", "Bigger apples", "How do you like them apples");?><!-- Mail body --><html><!-- rquired Start & end tags -->$mail_Products = Will display "Array"</html>

foreach/list = I can`t call since i can`t parse php operator within html.print_r = I can`t call since i cant parse php functions within html.I can`t use <php /> tags as well, since i cant parse server data within mail unless its pre-processed.Any ideas?

Share this post


Link to post
Share on other sites

Why don't you just create a string that represents the array?

$mail_products = array("Apple", "Bigger apples", "How do you like them apples");$products_str = "";foreach ($mail_products as $p) {	$products_str .= "$p<br>";}

$mail_products = array("Apple", "Bigger apples", "How do you like them apples");$products_str = print_r($mail_products, true);

Then just put $products_str into the mail body.P.S. there is no such thing as the <php> element.

Share this post


Link to post
Share on other sites
Why don't you just create a string that represents the array?
$mail_products = array("Apple", "Bigger apples", "How do you like them apples");$products_str = "";foreach ($mail_products as $p) {	$products_str .= "$p<br>";}

$mail_products = array("Apple", "Bigger apples", "How do you like them apples");$products_str = print_r($mail_products, true);

Then just put $products_str into the mail body.P.S. there is no such thing as the <php> element.

Why don't you just create a string that represents the array?
I don`t understand, The reason i am using an array, Is because i need to query a list of products from each user and send it via mail.Unless there is some sort of mathod to undo the array combination and just resolve it into a simple string?like so : $Test = array("help", "me");$Test_String = Some sort of function to convert the array into 1 long simple string...?
P.S. there is no such thing as the <php> element.
I believe that once you save your file as a .php, Your file is actually getting parsed by a php parser, and once it reaches a php tag,It start parsing the syntax in its own special way. Edited by Illasera

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...