how to do this ???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
z0rr0
Forum Newbie
Posts: 7
Joined: Tue Jun 03, 2003 1:22 am

how to do this ???

Post by z0rr0 »

how can i do this :

it'a a project for my universety and i really need it so here i go:

first step. i need to right my birth date (let's say 25.03.1982) ->the first number

2. from my birth date i have to do this - > 2+5+0+3+1+9+8+2 = 30 -> the second number

3. now 3+0 = 3 (if it was 34 thant it's 7,if it was a number over 10 (like 5+6 =11) then it's 1 etc.) -> third number

4. now 30 - 2*2 ( the first 2 is from my birthday date and the second 2 is a number to use at all situations) = 26

5. and now 2+6 (from the step number 4) = 8

6.now we have : 25.03.1982.30.3.26.8

7. i have 1 -> 1 times (from 1982 ); 2 ->3 times (from 25,1982 and 26);3 ->3 times(from 03,30 and 3);4 ->0 times(from and so on till 10 .

8. all this is going to a table like this:

-----------------------
1 | - | - |
-----------------------
222 | 5 | 88 |
----------------------
333 | 6 | 9 |
----------------------

how do i do this ? please help
THANKS
User avatar
discobean
Forum Commoner
Posts: 49
Joined: Sun May 18, 2003 9:06 pm
Location: Sydney, Australia
Contact:

here u go

Post by discobean »

This is as far as I got in the spare time I had...

I figure your a student, so u should figure out the rest of it yourself...

Mind you, I don't like the way it generates the third number, but pff, you'll get a pass eh

Code: Select all

$birthdate = "25.03.1982";

$first_number = preg_replace("/[^0-9]/", "", $birthdate);

$second_number = (string)addnums($first_number);

if(($third_number = $second_number[0]+$second_number[1]) >= 10)
	$third_number = 1;

$fourth_number = $second_number - ($birthdate[0] * 2);
$fifth_number = addnums($fourth_number);

echo <<<HTML
First Number: {$first_number}<br />
Second Number: {$second_number}<br />
Third Number: {$third_number}<br />
Fourth Number: {$fourth_number}<br />
Fifth Number: {$fifth_number}<br />
HTML;

function addnums($nums)
{
	foreach(preg_split("//", (string)$nums) as $num)
		$outnum+=$num;
	return $outnum;
}
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I really gave deleting discobean's post a thought but it's not me who has to decide wether to do your homework or not.
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

And all this for a universety.... :)
What a program ;)
z0rr0
Forum Newbie
Posts: 7
Joined: Tue Jun 03, 2003 1:22 am

Post by z0rr0 »

thanks a lot ... and sorry if i was to ... something :oops:
Post Reply