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

  • Home
  • SEARCH
  • 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 4382112
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:44:13+00:00 2026-05-21T12:44:13+00:00

Hey guys im trying to run through an array of checkboxes to add up

  • 0

Hey guys im trying to run through an array of checkboxes to add up a price and keep getting an unexpected } error and i cant figure out why:

            $price;
        foreach($_POST['extras'] as $extra)
            {
            if($extra == "Deodoriser"){
                        $price = $price + 10;
                    } elseif($extra == "Carpet Protector (5 litre)"){
                        $price = $price + 20
                    } elseif($extra == "Carpet Repair Tools"){
                        $price = $price + 30
                    } elseif($extra == "Furniture Moving Equipment"){
                        $price = $price + 40
                    } elseif($extra == "Furniture Tabs"){
                        $price = $price + 50
                    } elseif($extra == "Urine Decontamination Treatment"){
                        $price = $price + 60 }
            }

I now get this error
Parse error: syntax error, unexpected T_FOREACH in /home/fevsdiet/public_html/diycarpetcare.co.uk/booking/booking.event.processing.php on line 45

  • 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-21T12:44:13+00:00Added an answer on May 21, 2026 at 12:44 pm
    if($extra == "Deodoriser"){ 
        $price = $price + 10; 
    } elseif($extra == "Carpet Protector (5 litre)") { 
        $price = $price + 20; 
    } elseif($extra == "Carpet Repair Tools") { 
        $price = $price + 30; 
    } elseif($extra == "Furniture Moving Equipment") {
        $price = $price + 40; 
    } elseif($extra == "Furniture Tabs") {
        $price = $price + 50;
    } elseif($extra == "Urine Decontamination Treatment") {
        $price = $price + 60;
    } else {
        $price = 0;
    }
    

    Alternative:

    foreach($_POST['extras'] as $extra) {
        switch($extra) {
            case 'Deodoriser':
                $price = $price + 10;
                break;
            case 'Carpet Protector (5 litre)':
                $price = $price + 20;
                break;
            case 'Carpet Repair Tools':
                $price = $price + 30;
                break;
            case 'Furniture Moving Equipment':
                $price = $price + 40;
                break;
            case 'Furniture Tabs':
                $price = $price + 50;
                break;
            case 'Urine Decontamination Treatment':
                $price = $price + 60;
                break;
            // Could add a default as well
            default:
                $price = 0;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys, I am trying to run a proccess by submitting an AJAX form:
Hey, guys. Newbie to tomcat/apache, java returner here. I'm trying to run th step-by-step
Hey guys I'm trying to figure how pointers are returned by strcat(), so I
hey guys, im trying to run a script in the backend of my django
Hey guys I got a vps which run solusVM. I'm now trying to install
hey guys, i'm getting an exception on the following inner exception: {Value cannot be
Hey guys, I'm starting with Zend, and trying to understand the way it works
Hey guys I've been trying all day to get an ant file to automatically
Hey guys. I'm trying to change the image in a container with what I
Hey guys im trying to get a simple button masher up, What i want

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.