Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 07-26-2010, 08:02 PM Variable Ranges?
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
Is there a way to have a 'variable range'?

Such as if I was making a level system, it would be like this:

$level1="Level 1 desc is here";
$level2="Level 2 desc is here";
$level3-5 = "Level 3, 4, and 5 desc is here";

?

It's a whole lot easier than typing out EVERY SINGLE POSSIBLE LEVEL. Just wonderin'

Thanks!

-PG

Also, is there a way to do something along the lines of this?:

echo $level$newLevel

? For example, if $newLevel was 1 and $level would reference the $level1, $level2, $level3... variables, with $newLevel adding the number in?
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!

Last edited by Physicsguy; 07-26-2010 at 08:51 PM..
Physicsguy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-26-2010, 08:46 PM Re: Variable Ranges?
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
PHP Code:
$range 5;

for(
$i 1$i <= $range$i++)
{
     echo 
"Level $i desc is here";

__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 07-26-2010, 08:59 PM Re: Variable Ranges?
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
Thanks, Matt!

Do you by any chance have an answer to my second question? Thanks
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 07-26-2010, 09:37 PM Re: Variable Ranges?
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
I'm not 100% sure I get what you're saying but I think what you are trying to do is dynamically reference a variable:
PHP Code:
$foo 'bar';
$bar 'hello';

echo $
$foo//will output hello 
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 07-26-2010, 09:48 PM Re: Variable Ranges?
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
How exactly does that work? Does it take the next variable after it? Or does it output the variable name of the variable called?
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Variable Ranges?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.40880 seconds with 12 queries