Hi need help with a couple things here. At the bottom is the code I'm using the problem I'm having is I have a text box which stores the values for the people who're allowed to do certain features to my script (ie whoview = who can view it).
What my script does is checks if any of values in the array is in the specific text box and then sets a unique variable tobe selected (this is for my form).
An example of what the text box may look like (Super Administrator, Moderator, Member, Username1, Username2,). This is where I need the help because I also need to set a variable (ie for whoview use $whoview) tobe equal to the values of the textbox which is not in the array. I was also wondering if there was an easier way of doing my solution without setting up any functions.
Hope that makes sense and I'd be greatful if you could help. Thanx
Here's my script:
$ranks = array("Super Administrator", "Administrator", "Super Moderator", "Moderator", "Member"
;
for($i = 0; $i < count($ranks); $i++) {
if(eregi($ranks[$i], $set[whoview])) {
$rank = $ranks[$i] //HOW DO I GET IT SO THAT IT CONVERTS SPACES TO UNDERSCORES
$rank = "whoview$rank";
$$rank = "selected";
}
if(eregi($ranks[$i], $set[whocreate])) {
$rank = $ranks[$i] //HOW DO I GET IT SO THAT IT CONVERTS SPACES TO UNDERSCORES
$rank = "whoview$rank";
$$rank = "selected";
}
if(eregi($ranks[$i], $set[whoadd])) {
$rank = $ranks[$i] // HOW DO I GET IT SO THAT IT CONVERTS SPACES TO UNDERSCORES
$rank = "whoview$rank";
$$rank = "selected";
}
}
What my script does is checks if any of values in the array is in the specific text box and then sets a unique variable tobe selected (this is for my form).
An example of what the text box may look like (Super Administrator, Moderator, Member, Username1, Username2,). This is where I need the help because I also need to set a variable (ie for whoview use $whoview) tobe equal to the values of the textbox which is not in the array. I was also wondering if there was an easier way of doing my solution without setting up any functions.
Hope that makes sense and I'd be greatful if you could help. Thanx
Here's my script:
$ranks = array("Super Administrator", "Administrator", "Super Moderator", "Moderator", "Member"
for($i = 0; $i < count($ranks); $i++) {
if(eregi($ranks[$i], $set[whoview])) {
$rank = $ranks[$i] //HOW DO I GET IT SO THAT IT CONVERTS SPACES TO UNDERSCORES
$rank = "whoview$rank";
$$rank = "selected";
}
if(eregi($ranks[$i], $set[whocreate])) {
$rank = $ranks[$i] //HOW DO I GET IT SO THAT IT CONVERTS SPACES TO UNDERSCORES
$rank = "whoview$rank";
$$rank = "selected";
}
if(eregi($ranks[$i], $set[whoadd])) {
$rank = $ranks[$i] // HOW DO I GET IT SO THAT IT CONVERTS SPACES TO UNDERSCORES
$rank = "whoview$rank";
$$rank = "selected";
}
}