SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    CA
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    array_combine modification

    When I print_r($_POST) to determine what's being posted from my form, I get this:

    PHP Code:
    Array ( [name] => Array ( [0] => Joe [1] => [2] => [3] => [4] => [5] => ) [animal] => Array ( [0] => Dog  [1] => Cat [2] => [3] => [4] => [5] => ) [submit] => Validez 
    Then, I array_combine to (duh) combine the arrays, and I get this:

    PHP Code:
    Array ( [Joe] => Dog [] => ) 

    I'd like to get this:

    PHP Code:
    Array ( [Joe] => Dog [] => Cat
    Anyone know how I can accomplish this?

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and what if it was Tom instead of Joe?

    you have said the end result you want, but you havent said anything about why the result should be this. identify the rules which need to be applied.

    will the order of the elements and keys always be the same?

    a question to ask yourself.
    should i even be submitting this array via post in the first place? must i submit it in this format that is not what i want?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •