Results 1 to 4 of 4

Thread: Array help

  1. #1
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default Array help

    What can I use to make the keys and values of this array the keys and values of the main part of the array and not a sub array of the main.
    PHP Code:
    Array ( [0] => Array ( [id] => [art_title] => This my first news post [art_short_desc] => asdfr [art_keywords] => acfr [art_body] => I hope this works straight away [art_date] => 2011-06-27 17:12:03 ) ) 
    I want it to be like this
    PHP Code:
    Array ( [id] => [art_title] => This my first news post [art_short_desc] => asdfr [art_keywords] => acfr [art_body] => I hope this works straight away [art_date] => 2011-06-27 17:12:03 
    Without the first array 0 key.
    Last edited by fastsol1; 06-30-2011 at 11:29 PM.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Something as simple as...
    PHP Code:
    <?php
    $rusty_array 
    = array("0" =>
        array(
            
    "id"                   => 2,
            
    "art_title"            =>"This my first news post",
            
    "art_short_desc"       => "asdfr",
            
    "art_keywords"         => "acfr",
            
    "art_body"             => "I hope this works straight away",
            
    "art_date"             => "2011-06-27 17:12:03"
        
    )
    );

    $array $rusty_array[0]; //new array

    print_r($array);
    ... could do the job
    Jeremy | jfein.net

  3. The Following User Says Thank You to Nile For This Useful Post:

    fastsol1 (06-30-2011)

  4. #3
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    Holy crap, really. It's so simple it's mind boggling. Thanks!

  5. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    No problem, I'm glad to help

    In an effort to keep things organized, you have the option to set a thread to resolved when an issue is fixed. To make the status of the thread resolved:
    1. Go to your first post
    2. Edit your first post
    3. Click "Go Advanced"
    4. In the dropdown next to the title, select "RESOLVED"
    Jeremy | jfein.net

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
  •