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 6773099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:37:36+00:00 2026-05-26T15:37:36+00:00

I have an assignment that asks me to retrieve delimited text from form values.

  • 0

I have an assignment that asks me to retrieve delimited text from form values. The text is delimited with an asterisk (*). I have been trying to use the explode() function to do this, but I’m not having any luck. Here is my code:

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Bills</title>
<style>
body {
font-family:Verdana, Geneva, sans-serif;
}

.bad {
color:#FF0000;
}
</style>
</head>

<body>
<h1>My Bills</h1>

<?php 

echo "
<p><strong>Sort Order for Items:</strong> 
<form method='post'>";

$choice = $_POST['sort'];

if ($choice == 'ascending')
    echo "
<label for='ascending'>Ascending</label><input name='sort' type='radio' id='ascending' value='ascending' checked='checked' /> 

<label for='descending'>Descending</label><input name='sort' type='radio' value='descending' id='descending' />";

if ($choice == 'descending')
    echo "
<label for='ascending'>Ascending</label><input name='sort' type='radio' id='ascending' value='ascending' /> 

<label for='descending'>Descending</label><input name='sort' type='radio' value='descending' id='descending' checked='checked' />";

if ($choice == '')
    echo "
<label for='ascending'>Ascending</label><input name='sort' type='radio' id='ascending' value='ascending' checked='checked'  /> 

<label for='descending'>Descending</label><input name='sort' type='radio' value='descending' id='descending' />";

echo "
<table border='0' cellpadding='3' cellspacing='5'>
  <tr>
    <td><h4>Item</h4></td>
    <td><h4>Amount</h4></td>
  </tr>
";

for($row=1; $row<5;$row++)
    {

    $item_name='item_name'.$row;    
    $item_value = $_POST[$item_name];

    $amount_name='amount_name'.$row;    
    $amount_value = $_POST[$amount_name];


    $myelement = "$item_value*$amount_value*";
    $myarray = array($myelement);
    array_push($myarray, $myelement); //Adds $myelement to the end of the $myarray array
    foreach ($myarray as $myName)
    {
    $list = explode("*", $myName);
    echo "<br>".$list[0];
    }

echo 
"<tr>
    <td><input type='text' name='$item_name' value='$item_value'  /></td>
    <td><input type='text' name='$amount_name' value='$amount_value' /></td>
";  

    if (!empty($amount_value))
    {
            if(is_numeric($amount_value))
            {
            $total = $total + $amount_value;
            }
            else {
        echo    
            "<td class='bad'>Amount Invalid: $amount_value</td>";
            $error_count++;
            }
    }


echo"   
  </tr>
";

    }
echo " 

<tr>
    <td colspan='2'>
    <input name='' type='submit' value='Submit' />
    </td>
</table>
    ";
    if ($error_count > 0)
    {
    echo "<br /><span class='bad' />Errors: $error_count</span>";
    }
    else
    {
    echo "<br />Total: $total";
    }


?>
</form>


</body>
</html>
  • 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-26T15:37:37+00:00Added an answer on May 26, 2026 at 3:37 pm

    I don’t know what your crazy code do, but this is proper syntax:

    $list = explode("*", $sort_line[$array_counter]);
    echo "<br>".$list[0];   
    

    or

    list($list) = explode("*", $sort_line[$array_counter]);
    echo "<br>".$list;   
    

    See http://php.net/manual/en/function.list.php

    And i suppose you should change $sort_line[$array_counter] to $myName

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a homework assignment that asks to create an order form. The order
I am working on a short java assignment that I have been set. The
hey guys, i have a c++ programming assignment that asks me to create a
Good day, I have been given an assignment that gets data off a CSV
I've been working on a school assignment that makes pretty heavy use of vectors,
I have an assignment that converts dates from one calendar system to another. The
I have this school assignment that I've been working on and am totally stumped
I'm very new to XML and XSLT. I have a homework assignment that asks
I currently have a school assignment that involves both PHP and asp.net. Now the
I'm working on an assignment that is telling me to assume that I have

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.