..oO(SM)
>I've posted the following question in a math group. I'll keep you posted:
I need to find a mathematical formula for this next problem...
I have a list containing 13 items. The list is dynamic, wich means that sometimes it could contains 20 items or 35 items o only 4 items.
I want to show the items in groups of 4. Again, this is dynamic. Sometimes i want to show the items in groups of 11, 2, etc...
So, if i have 34 items and i want to show it in groups of 10, I would end up having 4 groups (3 groups of 10, and 1 group of 4)... So far so good. Let's continue. If item 'joe' is the 12th item, then item 'joe' is in group 2. right? If the item 'banana' is the 8th item, then item 'banana' is in group 1...and so on...
<?php
$itemsPerGroup = 10;
$itemPosition = 12;
$group = ceil($itemPosit ion/$itemsPerGroup) ;
var_dump($group );
?>
Micha 1 1291
On Oct 9, 6:37*pm, Michael Fesser <neti...@gmx.de wrote:
.oO(SM)
I've posted the following question in a math group. I'll keep you
posted:
I need to find a mathematical formula for this next problem...
I have a list containing 13 items. The list is dynamic, wich means
that sometimes it could contains 20 items or 35 items o only 4 items.
I want to show the items in groups of 4. Again, this is dynamic.
Sometimes i want to show the items in groups of 11, 2, etc...
So, if i have 34 items and i want to show it in groups of 10, I would
end up having 4 groups (3 groups of 10, and 1 group of 4)... So far so
good. Let's continue. If item 'joe' is the 12th item, then item 'joe'
is in group 2. right? If the item 'banana' is the 8th item, then item
'banana' is in group 1...and so on...
<?php
$itemsPerGroup = 10;
$itemPosition = 12;
$group = ceil($itemPosit ion/$itemsPerGroup) ;
var_dump($group );
?>
Micha
Thanks, just what i need it. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Wim Smit |
last post by:
I am trying to put the following math formula in php, but I know to little
of math to do it I guess, maybe somebody can help me out.
This is the formula:
x = (-ln(1) - ln(y/100))*100*z
The values for y and z will be submitted via a form.
Any help is greatly apreciated.
|
by: Frank Millman |
last post by:
Hi all
I was helping my niece with her trigonometry homework last night. Her
calculator's batteries were flat, so I thought I would use Python's
math module to calculate sin, cos, and tan.
I tried the example in the text book first, to ensure that I was
getting the correct result, but it did not agree. Then my wife had the
idea of using...
|
by: cwdjrxyz |
last post by:
Javascript has a very small math function list. However there is no
reason that this list can not be extended greatly. Speed is not an
issue, unless you nest complicated calculations several levels deep. In
that case you need much more ram than a PC has to store functions
calculated in loops so that you do not have to recalculate every time...
|
by: Woody Splawn |
last post by:
I am trying to determine the age of a person based on two dates, the Date of
Birth and Today().
I have a function that does this but it is kludgey and is giving me an age
that is pretty close but only because I have figured into the equation
(manually) the approximate number of leap years.
The code reads:
Dim TS As New TimeSpan
Dim...
|
by: kirby.urner |
last post by:
Cyber-curricula have a leveling aspect, as kids
nearer Katrina's epicenter tune in and bliss out
on 'Warriors of the Net' (why wait for stupid big
dummy textbooks to catch up?). They feel more
empowered by Python and Ubuntu than by any
King's English I'd warrant, given how the latter
has been dumbed down (slowed, degraded) by
unimaginative...
| |
by: Joseph Geretz |
last post by:
I need to calculate miles per degree longitude, which obviously depends on
latitude since lines of longitude converge at the poles. Via Google, I've
come up with the following calculation:
private const double MilesPerDegLat = 69.04;
private const double EarthRadiusMiles = 3963.1676;
private static double PiDiv180 = Math.PI / 180;
double...
|
by: lbrtchx |
last post by:
I am trying to write up a page with Math formulas (statistical ones)
~
http://www.geocities.com/tekmonk2005/OnLineStats02.html
~
The thing is that I am not able to make it look OK using HTML. I
would like to somehow mark up parenthesis using the character entities
for vertical bars and solid front and back slashes, but
~
<td...
|
by: merarajesh |
last post by:
hi,
I am developing intensity of wave in physics.
I am using system.math in c#.
every thing is fine. but the result of Intensity is not well.
my formula is:-
I=4*a2*cos2(delta/2);
delta=2pi/lambda*trangle;
trangle=dx/d
lambda=constant*10pow-10;
|
by: Lenni |
last post by:
Hi,
I'm currently writing a web application for bicycle wheel builders
that calculate the spoke length for all sorts of variations of hubs
and rims.
I have translated the formula from an Excel spreadsheet and in
JavaScript it looks like this:
var sll=Math.sqrt(Math.pow(((fdl/2*Math.sin((2*Math.PI*cross)))/
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| | |