Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7400649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:16:48+00:00 2026-05-29T04:16:48+00:00

I have a array of objects and wants to create an online invoice to

  • 0

I have a array of objects and wants to create an online invoice to be sent on mail . For this I have modified the message as below :

function mail_invoice($buyer_info,$items_info ,$date,$final_amount)
{
    global $template;

    //var_dump($buyer_info);


    $to = $buyer_info->email;
    $from_mail = 'info@7sisters.in';
    //echo $msg.$to.$from;sender_mail
    $subject = "Your Invoice";
    $message = "Your Shopping Details";
    $message .= '
            <h2>RETAIL INVOICE</h2>
                <p>
                    SRI SAI VENTURES PVT LTD.<br />
                    House Number 13A<br />
                    Nizarapar<br />
                    Guwahati - 781003<br />
                    Assam
                </p>

                <p>
                    Buyer <br />
                    <b>'.$buyer_info->fname.' '.$buyer_info->lname.'</b><br />
                    '.$buyer_info->address.'<br />
                    PIN - '.$buyer_info->pin.'<br />
                    PHONE '.$buyer_info->phone.'<br />
                </p>

                <p>
                    Dispatch Date : '.$date.'
                </p>
                <table>
                    <tr>
                        <th>Sl No</th>
                        <th>Description of goods</th>
                        <th>Quantity</th>
                        <th>Rate</th>
                        <th>Amount</th>
                    </tr>'. 

                (foreach $items_info as $a=>$v).'      <----line no 1025
                    <tr>
                        <td>'.++$ind.'</td>
                        <td>'.$v->brand.','.$v->model.'</td>
                        <td>'.$v->quantity.'</td>
                        <td>'.$v->price.'</td>
                        <td>'.$v->total_cost.'</td>
                    </tr>'.
                {/foreach}
                    .'<tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>Total Cost </td>
                        <td>'.$final_amount.'</td>
                    </tr>
                </table>





    ';
    $from = $from_mail;
    //$headers = "From:" . $from;

    $headers = "From:" . $from . "\r\n" .
               "Reply-To:" . $from . "\r\n" .
               "X-Mailer: PHP/" . phpversion();
    $headers .= 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";        


    mail($to,$subject,$message,$headers);

    //$template->main_content = $template->fetch(TEMPLATE_DIR . 'messag_sent_to_friend.html');      
}

But I am getting error message Parse error: syntax error, unexpected T_FOREACH in C:\wamp\www\eshop\class\base\user.base.class.php on line 1025 . Whats wrong I am doing? Or I can’t use foreach there . Please help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:16:49+00:00Added an answer on May 29, 2026 at 4:16 am

    You cannot nest a foreach statement in string concatenation. Just split it:

        ....
                        <th>Amount</th>
                    </tr>';
    
        foreach $items_info as $a=>$v){
            $message .= '<tr>
                        <td>'.++$ind.'</td>        
                        <td>'.$v->brand.','.$v->model.'</td>
                        <td>'.$v->quantity.'</td>
                        <td>'.$v->price.'</td>
                        <td>'.$v->total_cost.'</td>
                    </tr>';
        }
        $message .= '<tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
        ....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of custom objects. MyCustomArr[]. I want to convert this to
I have array with colors as its objects. I want to create an image
I have a method that needs to create an array of objects of a
I have an array of classes and I want to create objects of them.
I have an array of objects, and want the objects to be able to
I have a 2-dimensional array of objects and I basically want to databind each
I have an array of objects which populate a UITableView . When a user
I have an Array of Objects that need the duplicates removed/filtered. I was going
I have an array of objects that have QTTime structs as attributes. The objects
I have an array of objects in MATLAB and I've called their constructors in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.