today's support questions is regarding PHP programming.

Webune offers PHP hosting at low prices!!!

We received a support question regarding how you can combine or put together different strings to execute as one?

that was the question. as you can see its not very clear as to what the user wanted to achieve. after gathering more information, we became more aware that it really was a complicated question but the solution was simple.

we started to work with the user and ask him what he wanted to achieve or if we can get a code example of what he was trying to do. so this is what we got:


<?php
$PermsCmd1 = 'command 1';
$PermsCmd2 = 'command 2';
$PermsCmd3 = 'command 3';
$PermsCmd4 = 'command 4';
$PermsCmd5 = 'command 5';
for($counter =1; $counter <= 5; $counter++) {
	echo ($PermsCmd.$counter).'<BR>';		 		
}
?>


as you can see, we have a loop with 5 different strings, each string has begins with $PermsCmd and ends with a chronological number,

then we have a for loop. and we try to execute each string with this loop

what do you think the output is going to be?

this is what the user expected: command 1
command 2
command 3
command 4
command 5


but that was not the case, instead the ouput looked like this: 1
2
3
4
5


to achieve the output the user wanted, we would have to use an array and our code would look like this:

<?php
$PermsCmd['1'] = 'command 1';
$PermsCmd['2'] = 'command 2';
$PermsCmd['3'] = 'command 3';
$PermsCmd['4'] = 'command 4';
$PermsCmd['5'] = 'command 5';
for($counter =1; $counter <= 5; $counter++) {
	echo ($PermsCmd[$counter]).'<BR>';		 		
}
?>


now the output will look like this:

command 1
command 2
command 3
command 4
command 5