Is there is simple and quick way to convert php array from
$actions = Array ( [visits-visit] => Array (
[0] => index
[1] => edit
[2] => add
[3] => delete
[4] => search
)
)
to
Array ( [visits-visit] => Array ( index ,edit ,add ,delete, search ) )
I have an array in the first format, and need to add it as this
$this->allow($_userRole, 'module-contr', array( index ,edit ,add ,delete, search));
when I make like this
$this->allow($_userRole, 'module-contr', array( $actions ));
it’s not accepted as I want.
Those two arrays are essentially the same… The first array is simply how it will be displayed should you decide to print it out (with
print_r()for example). When you are defining an array IE. creating an array with values already inside it, you would write something like this –Essentially the array you are creating already has the numerical indexes implied by the order of their appearance… The element at index
[0]is the stringindex. At index[1]you have the stringedit… At index[2]you haveadd… and so on…Another thing to note is this line that you stated –
With the last parameter, what you are essentially doing is passing the
$actionswithin an additional array! What you are doing is creating a new array with the first element equal to$actions. I think you should remove that additional array by simply passing$actionsand notarray( $actions )I hope this cleared things up a little bit…