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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:52:14+00:00 2026-05-30T05:52:14+00:00

My current array [attributes] => Array ( [0] => Color, Black, 1 [1] =>

  • 0

My current array

[attributes] => Array
    (
        [0] => Color, Black, 1
        [1] => Size, S, 0
    )

On foreach how to display this array to be something like this

<ul>
  <li class="alignleft">Color : Black</li>
  <li class="alignright">$ 1.00</li>
  <li class="alignleft">Size : S</li>
  <li class="alignright">$ 0.00</li>
</ul>

What I’ve done..

<ul>            
<?php
$c = true;
foreach ($_SESSION['checkout']['attributes'] as $key => $value) {
    echo '<li'.(($c=!$c)?' class="alignright"':' class="alignleft"').">$value</div>";
}
?>
</ul>

  • 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-30T05:52:15+00:00Added an answer on May 30, 2026 at 5:52 am

    As long as all your array entries look like that, this should work:

    <ul>            
    <?php
    foreach ($_SESSION['checkout']['attributes'] as $key => $value) {
        $arr = explode(",", $value);
        echo '<li class="alignleft">' . $arr[0] . ' : ' . $arr[1] . '</li>';
        echo '<li class="alignright">$' . number_format($arr[2], 2) . '</li>';
    }
    ?>
    </ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My current code looks like the following. How can I pass my array to
My current code is this $swift = email::connect(); $swift->setSubject('hello') ->setFrom(array('alex@example.com.au' => 'Alex')) ->setTo(array('alex@example.com.au' =>
I have this: [1]=> object(SimpleXMLElement)#6 (1) { [@attributes]=> array(14) { [name]=> string(5) MySQL [acknowledged]=>
This is my current array which keep a first character from the value Array
current code I've built function to do something over collection of jQuery elements: var
I am refactoring some existing Delphi code into a class. The current code uses
In this post https://codereview.stackexchange.com/questions/5745/dynamic-array-improvements-0 What does this mean? Sorry if the question is vague..I
I have a single UIView with some labels that display attributes from objects inside
on a website i want to do this: (simplified) myHandlers = new Array(); for(var
Current, I've got a stored procedure that has a main goal of doing a

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.