Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Posts
    419
    Thanks
    18
    Thanked 2 Times in 2 Posts

    keys and value for specific _Post

    Probably a simple one, but I'm not sure.

    EDIT: starting with array(2) { ["chosen"]=> string(8) "tactical" ["what_category"]=> string(10) "Buttstocks" }
    EDIT: I want to add "What_category" as the key, and "tactical" as the value. I've got myself twisted around again. dang!

    If I have a simple array_push that adds three or four times to:

    PHP Code:
    $variable $_POST['chosen'];
    array_push($_SESSION['options_picked'],$variable); 
    I get eventually an array that lists something like
    Array ( [0] => result1 [1] => Result2 [2] => Result3 [3] => 21 [4] => result4 [5] => result5 )


    I want to keep the post key with it: so I have:
    Array ( [categoryA] => result1 [categoryB] => Result2 [categoryC] => Result3 [categoryD] => 21 [CategoryE] => result4 [CategoryF] => result5 )
    Last edited by turpentyne; 08-01-2012 at 11:11 PM.

  • #2
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    738
    Thanks
    20
    Thanked 85 Times in 85 Posts
    something like:

    PHP Code:
    $result = array();

    foreach (
    $_POST as $key => $post){
    $result[$key] = $post;



  •  

    Posting Permissions

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