Log in

View Full Version : Resolved Array help



fastsol1
06-30-2011, 03:40 AM
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.

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 ) )
I want it to be like this

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 )
Without the first array 0 key.

Nile
06-30-2011, 04:09 AM
Something as simple as...

<?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

fastsol1
06-30-2011, 11:12 AM
Holy crap, really. It's so simple it's mind boggling. Thanks!

Nile
06-30-2011, 05:42 PM
No problem, I'm glad to help :D

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"