![]() |
A little challange for you all
Well, hopefully it will be a challange :-D
Here's what you have to do: PHP Code:
Rules: The variable name must be 999 and it must contain the string 'Hello' and you must echo the variable to display the string. ---> First one to post a working answer wins a cookie! :-) Good luck all! Alan |
I know, I know! But to keep it a challenge I won't reveal :-) ! I saw this in a book I have a while ago - quite crafty, though I certainly wouldn't recommend naming your variables like this.
|
BINGO!!!!
<?php $test = array('9','9','9'); $test[0] = "he"; $test[1] = "ll"; $test[2] = "o"; $output = "$test[0]$test[1]$test[2]"; echo $output; ?> |
You get half a cookie for keeping quiet :-D
Alan |
I blogged about this sort of thing not very long ago, would it be rude to claim the cookie before many others take a stab at it? Thinking about it, lets be sporting. If you can think up any weird and wacky solutions (sarmenhb had a good stab at it!), they might not be awarded a cookie but it'll be fun anyway. :-P
|
Good attempt sarmenhb but there isn't a variable named 999 which contains the string 'Hello' - you have a variable called $test containing an array of 'Hello' parts :-)
Good thinking though! Alan |
Quote:
BINGO!!! BINGO!!!! <?php $test = array('9','9','9'); $test[0] = "he"; $test[1] = "ll"; $test[2] = "o"; $output = "$test[0]$test[1]$test[2]"; echo $output; ?> |
Another good attempt, but this time you are echo'ing a variable named 'output', not '999' :-)
Keep trying though! That cookies waiting! Alan |
Quote:
does that work? |
Afraid not :-) You need to have a variable named '999', that contain the string 'Hello' (string, not array), and then echo that variable to display the string 'Hello' :-)
Alan |
Quote:
Code:
<?php |
ok, turned out not to be such a challange after all :D Sarmenhb wins the Cookie!
An alternative way (and the way I was thinking of when I wrote the question is to use variable variables :) Eg: PHP Code:
Alan |
Yay, how's that cookie taste sarmenhb? :-)
Time for some more little challenges methinks! |
I suck D: (chars)
|
I really like this idea of challenges lol i think should have a area for these kind of challenges that the mods and admins can set maybe come up with some kind of point system :-P
Heres one for ya What can run but never walks, has a mouth but never talks, has a head but never weeps, has a bed but never sleeps? :-D |
Quote:
|
Quote:
I have holes on the top and bottom. I have holes on my left and on my right. And I have holes in the middle, yet I still hold water. What am I? |
A sponge
Temples will fall, and mountains will crumble no man can survive it's call, what am I? |
Quote:
|
nay, though I can see where that answer would fill the perquisite answers.
|
| All times are GMT. The time now is 12:23 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0