php loop through 2D array

Posted on 2010-11-13
Medium Priority
Last Modified: 2012-05-10
I access the following values like this.
    //next row

Open in new window

However I need to consolidate this to


Open in new window

2 other strange things.  The values are strings and I need them to be decimals(2 decimal points) and also the min and the max for price and low accross all the rows
Question by:casit
LVL 31

Expert Comment

by:Marco Gasi
ID: 34130343
Can you post the array and the code your using to loop? Thanks
LVL 111

Accepted Solution

Ray Paseur earned 2000 total points
ID: 34131194
We need to see a little bit more of the code to help you.  What you have here is Object-Oriented Notation (and it looks a little confused):


What you would probably want is an iterator like foreach() if you really need to reassign these variables to new variables.  But with PHP's loose data typing, you might be able to simply use the values "as is" or multiply each by 1.0 to get a floating point value.  PHP has no such thing as a "decimal" value.  You can sort() arrays to find the min and max values - after sorting you can use reset()  and end() to find these values after a sort.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question