Currently i have multiple select tags that have almost the same option choices, what i did now is used file_get_contents to get the value of option tags and assign them to the select tags. but i wanted to create a more efficient way of doing this since when i tried to add an if condition inside the file for the file_get_contents to filter out some extra option tags that should only be available to some select tags it did not work. so i was wondering what is the best approach for this?
basically i used file_get_contents to get the file that contains the basic option tags and assign them to the select tags.
thanks
-magician
Code for some:
some.php
<option>1</option>
<option>2</option>
... you get the picture
for other files.php
<select>
$hello = file_get_contents("some.php");
echo $hello;
</select>
now when i add a condition at some.php ie
if($right=1)
{
this is only for this page
}
//this does not work instead it displays it to all select tags.
in my opinion, file_get_contents is used to retrieve data from a static file (like a txt file), store it into a string and do further processing.
To achieve what you are trying to do, you would need to use the
includedirective, since you obviously want variables from the first page to be available for theifstatement in the second pageAs the manual states, “When a file is included, the code it contains inherits the variable scope of the line on which the include occurs. Any variables available at that line in the calling file will be available within the called file”