1

I have an array as such

Array
(
[1] => Array
    (
        [0] => PrettyName1
        [1] => PrettyName2
        [2] => PrettyName3
    )

[2] => Array
    (
        [0] => UglyURL1
        [1] => UglyURL2
        [2] => UglyURL3
    )

)

I want to be able to put these into an array for a code-igniter template, well when I push and merge arrays I end up messing the whole thing up. Can someone show me the proper way to merge these arrays? I need something like

Array
(
    PrettyName1 => UglyURL1
    PrettyName2 => UglyURL2
    PrettyName3 => UglyURL3
)
3
  • 1
    This representation is not possible. Do you mean Array (PrettyName1 => UglyURL1, PrettyName2 => UglyURL2, PrettyName3 => UglyURL3) ? Commented Jan 6, 2013 at 16:27
  • 1
    You should build the array as you expect to use it later on. Commented Jan 6, 2013 at 16:28
  • Do you know the size of the array? or is it random? Commented Jan 6, 2013 at 16:28

1 Answer 1

5

Maybe something like this array_combine($ar[1], $ar[2]) ?

Sign up to request clarification or add additional context in comments.

2 Comments

Oh wow, thanks for this! I had no clue such function existed, makes this a WHOLE lot simpler! I'll accept your answer once it allows me.
@Robby Duke, PHP has thousands of functions. Learn them and be a better PHP Developer.