Results 1 to 14 of 14
Thread: PHP Challenge #3
-
08-10-2002, 12:17 PM #1Aspiring Evangelist
- Join Date
- Mar 2002
- Location
- Texas
- Posts
- 354
PHP Challenge #3
And here is your 3rd challenge. It's getting a little harder ;-)
TODO: Write a script to print to the browser a different url every day of the month with a different category of url for each day of the week using a multi-dimensional array and no conditional statement
-
08-10-2002, 12:39 PM #2Web Hosting Master
- Join Date
- Jan 2002
- Location
- Kuwait
- Posts
- 679
Can you explain a bit more with an example of what will happen in different days?
-
08-10-2002, 12:44 PM #3Aspiring Evangelist
- Join Date
- Mar 2002
- Location
- Texas
- Posts
- 354
Make a multi-dimensional array with Differant categories of URLs. So say, monday gets a url from the car category, tuesday gets one from the hobbies category and so on. then next monday comes around and they get a differant URL from the car category.
-
08-10-2002, 02:11 PM #4Web Hosting Master
- Join Date
- Jan 2002
- Location
- Kuwait
- Posts
- 679
Oh, ok. I get it now
-
08-10-2002, 02:34 PM #5Web Hosting Master
- Join Date
- Jan 2002
- Location
- Kuwait
- Posts
- 679
PHP Code:<?php
// Mon -- Cars
$links[0][1]['url'] = 'Cars.com';
$links[0][1]['name'] = 'http://www.cars.com/';
$links[0][2]['url'] = 'Cars.com';
$links[0][2]['name'] = 'http://www.cars.com/';
$links[0][3]['url'] = 'Cars.com';
$links[0][3]['name'] = 'http://www.cars.com/';
$links[0][4]['url'] = 'Cars.com';
$links[0][4]['name'] = 'http://www.cars.com/';
$links[0][5]['url'] = 'Cars.com';
$links[0][5]['name'] = 'http://www.cars.com/';
// Tue -- Cars
$links[1][1]['url'] = 'Cars.com';
$links[1][1]['name'] = 'http://www.cars.com/';
$links[1][2]['url'] = 'Cars.com';
$links[1][2]['name'] = 'http://www.cars.com/';
$links[1][3]['url'] = 'Cars.com';
$links[1][3]['name'] = 'http://www.cars.com/';
$links[1][4]['url'] = 'Cars.com';
$links[1][4]['name'] = 'http://www.cars.com/';
$links[1][5]['url'] = 'Cars.com';
$links[1][5]['name'] = 'http://www.cars.com/';
// Wed -- Cars
$links[2][1]['url'] = 'Cars.com';
$links[2][1]['name'] = 'http://www.cars.com/';
$links[2][2]['url'] = 'Cars.com';
$links[2][2]['name'] = 'http://www.cars.com/';
$links[2][3]['url'] = 'Cars.com';
$links[2][3]['name'] = 'http://www.cars.com/';
$links[2][4]['url'] = 'Cars.com';
$links[2][4]['name'] = 'http://www.cars.com/';
$links[2][5]['url'] = 'Cars.com';
$links[2][5]['name'] = 'http://www.cars.com/';
// Thu -- Cars
$links[3][1]['url'] = 'Cars.com';
$links[3][1]['name'] = 'http://www.cars.com/';
$links[3][2]['url'] = 'Cars.com';
$links[3][2]['name'] = 'http://www.cars.com/';
$links[3][3]['url'] = 'Cars.com';
$links[3][3]['name'] = 'http://www.cars.com/';
$links[3][4]['url'] = 'Cars.com';
$links[3][4]['name'] = 'http://www.cars.com/';
$links[3][5]['url'] = 'Cars.com';
$links[3][5]['name'] = 'http://www.cars.com/';
// Fri -- Cars
$links[4][1]['url'] = 'Cars.com';
$links[4][1]['name'] = 'http://www.cars.com/';
$links[4][2]['url'] = 'Cars.com';
$links[4][2]['name'] = 'http://www.cars.com/';
$links[4][3]['url'] = 'Cars.com';
$links[4][3]['name'] = 'http://www.cars.com/';
$links[4][4]['url'] = 'Cars.com';
$links[4][4]['name'] = 'http://www.cars.com/';
$links[4][5]['url'] = 'Cars.com';
$links[4][5]['name'] = 'http://www.cars.com/';
// Sat -- Cars
$links[5][1]['url'] = 'Cars.com';
$links[5][1]['name'] = 'http://www.cars.com/';
$links[5][2]['url'] = 'Cars.com';
$links[5][2]['name'] = 'http://www.cars.com/';
$links[5][3]['url'] = 'Cars.com';
$links[5][3]['name'] = 'http://www.cars.com/';
$links[5][4]['url'] = 'Cars.com';
$links[5][4]['name'] = 'http://www.cars.com/';
$links[5][5]['url'] = 'Cars.com';
$links[5][5]['name'] = 'http://www.cars.com/';
// Sun -- Cars
$links[6][1]['url'] = 'Cars.com';
$links[6][1]['name'] = 'http://www.cars.com/';
$links[6][2]['url'] = 'Cars.com';
$links[6][2]['name'] = 'http://www.cars.com/';
$links[6][3]['url'] = 'Cars.com';
$links[6][3]['name'] = 'http://www.cars.com/';
$links[6][4]['url'] = 'Cars.com';
$links[6][4]['name'] = 'http://www.cars.com/';
$links[6][5]['url'] = 'Cars.com';
$links[6][5]['name'] = 'http://www.cars.com/';
// here comes the logic
$link = $links[intval(date('w'))][(intval(date('j')) % 5) + 1];
echo "<a href='$link[url]'>$link[name]</a>";
?>
-
08-10-2002, 02:51 PM #6Registered User
- Join Date
- Mar 2002
- Posts
- 1,003
can someone do perl challange please?
-
08-10-2002, 03:10 PM #7Web Hosting Master
- Join Date
- Dec 2001
- Posts
- 1,372
Originally posted by Shyne
can someone do perl challange please?
Simon
-
08-10-2002, 04:08 PM #8Junior Guru
- Join Date
- Jul 2002
- Location
- Canada
- Posts
- 248
Originally posted by SimonMc
Or a cut and paste challenge...or even a watching paint dry challenge.
Simon
-
08-10-2002, 04:11 PM #9Aspiring Evangelist
- Join Date
- Mar 2002
- Location
- Texas
- Posts
- 354
why is everyone here using intval when they do the date lol
-
08-10-2002, 04:20 PM #10Web Hosting Master
- Join Date
- Dec 2001
- Posts
- 1,372
Originally posted by DoobyWho
why is everyone here using intval when they do the date lol
Simon
-
08-10-2002, 04:24 PM #11Aspiring Evangelist
- Join Date
- Mar 2002
- Location
- Texas
- Posts
- 354
-
08-11-2002, 02:25 PM #12Web Hosting Master
- Join Date
- Jan 2002
- Location
- Kuwait
- Posts
- 679
Originally posted by DoobyWho
why is everyone here using intval when they do the date lol
-
08-11-2002, 03:28 PM #13Junior Guru Wannabe
- Join Date
- May 2002
- Posts
- 78
Code:$links[0][1]['url'] = 'Cars.com'; $links[0][1]['name'] = 'http://www.cars.com/';
-
08-11-2002, 03:43 PM #14Aspiring Evangelist
- Join Date
- Mar 2002
- Location
- Texas
- Posts
- 354
lol. I didn't even notice that. Good job. I guess they had it backwords.