LinuxQuestions.org
Visit the LQ Articles and Editorials section
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, 02: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, 02:46 PM   #2
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,614

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


Last edited by keefaz; 06-17-2004 at 02:47 PM.
 
Old 06-17-2004, 03: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, 03:56 PM   #4
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,614

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

 
Old 06-17-2004, 04: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, 11:00 AM   #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, 01:03 PM   #7
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,614

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 08:37 PM
Cannot set LD_LIBRARY_PATH in .cshrc (able to set other env variables) senthilpr_in Linux - Newbie 4 02-26-2007 12:46 PM
how to set environmental variables chakkerz Linux - Newbie 8 07-01-2004 03:06 AM
facing problem in increment operator of set :infinite LOOP ashwinipahuja Programming 0 06-03-2004 12:05 AM
Help with the currently set environment variables!! apoc013 Linux - Newbie 6 01-21-2004 01:28 AM


All times are GMT -5. The time now is 03:39 AM.

Main Menu
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