LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 06-17-2004, 03:41 PM   #1
Ctawp
Member
 
Registered: Jul 2003
Location: Chicago, IL
Distribution: Fedora Core 4
Posts: 58

Rep: Reputation: 15
PHP set of variables increment?


Alright, so I'm wondering if there is any way to do something like the following:

while ($count<8){
echo $i_need_incremented_"$count";
$count++;
}

such that the echo outputs what is contained inside $i_need_incremented_0 the first time, $i_need_incremented_1 the second time, and so on.

-Chris
 
Old 06-17-2004, 03:46 PM   #2
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,617

Rep: Reputation: 136Reputation: 136
PHP Code:
while ( $count 
{
    echo 
"\$i_need_incremented_$count";
    
$count++;


Last edited by keefaz; 06-17-2004 at 03:47 PM.
 
Old 06-17-2004, 04:32 PM   #3
Ctawp
Member
 
Registered: Jul 2003
Location: Chicago, IL
Distribution: Fedora Core 4
Posts: 58

Original Poster
Rep: Reputation: 15
that doesn't output the contents of it though?
 
Old 06-17-2004, 04:56 PM   #4
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,617

Rep: Reputation: 136Reputation: 136
Well I am sorry
PHP Code:
while ( $count )
{
    echo ${
"i_need_incremented_$count"};
    
$count++;

 
Old 06-17-2004, 05:03 PM   #5
Ctawp
Member
 
Registered: Jul 2003
Location: Chicago, IL
Distribution: Fedora Core 4
Posts: 58

Original Poster
Rep: Reputation: 15
Awesome, thank you thank you. You're my new best friend.
 
Old 06-18-2004, 12:00 PM   #6
Ctawp
Member
 
Registered: Jul 2003
Location: Chicago, IL
Distribution: Fedora Core 4
Posts: 58

Original Poster
Rep: Reputation: 15
Any way for php to parse this so I can use that specific variable in an if statement kinda thing?

-Chris
 
Old 06-18-2004, 02:03 PM   #7
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,617

Rep: Reputation: 136Reputation: 136
PHP Code:
while ( $count )
{
    
$tmp = ${"i_need_incremented_$count"};

    if( 
$tmp == "You know what" )
    {
        echo 
"I know that\n";
    }

 
  


Reply


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Are PHP session variables held in memory when you leave a PHP site? Locura Programming 11 11-16-2008 09:37 PM
Cannot set LD_LIBRARY_PATH in .cshrc (able to set other env variables) senthilpr_in Linux - Newbie 4 02-26-2007 01:46 PM
how to set environmental variables chakkerz Linux - Newbie 8 07-01-2004 04:06 AM
facing problem in increment operator of set :infinite LOOP ashwinipahuja Programming 0 06-03-2004 01:05 AM
Help with the currently set environment variables!! apoc013 Linux - Newbie 6 01-21-2004 02:28 AM


All times are GMT -5. The time now is 06:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration