Jump to content

Is there anyway to do this?


l0ve2hat3

Recommended Posts

You can use variable variables. I'll let you look up in the manual how, because they are not the best way of using sets of related data.

 

Any time you have a set (two or more) of related data, use an array instead of sequentially named variables. Using variable variables are 3 times slower than an array and the code necessary to set create, keep track of how many of them there are, and access them is more complicated than if you just use an array.

Link to comment
Share on other sites

You can't create a variable or use it's value in the manner in which you have tried to do. I recommend using an array:

 

<?php
$josh1[] = "it worked";
for($i=0;$i<=3;$i++){
     if(isset($jost1["$i"])){
          echo $josh1["$i"];
     }
}
?>

Link to comment
Share on other sites

My first hand experience with variable variables was that I was in here a while back trying to use them and it was said that it couldn't be done...

 

Probably reading this will help - http://www.php.net/manual/en/language.variables.variable.php

 

Variable variables do exist. Please don't post information unless you have first hand knowledge of what you are posting.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.