LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 862 users online 158576 members 1328 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Video | Dictionary | News | FAQ
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
6 online / 40 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic

Array transformations in PHP
Replies: 2Last Post April 25 11:23am by i who have nothing
Single page for this topic Email Print Favorite
( pleaseremove )


Dairy Product Addict

Patron
Tech Support Leader
Reply
OK, I'm trying to transform the following arrays in PHP into one multi-dimensional array. Given its 2 in the morning this is beyond my poor brain.

The arrays are:
Code:

Array
(
   [3] => title1
   [4] => title2
   [5] => title3
   [6] => title4
   [7] => title5
   [8] => title6
   [9] => title7
)
Array
(
   [3] => description1
   [4] => description2
   [5] => description3
   [6] => description4
   [7] => description5
   [8] => description6
   [9] => description7
)
Array
(
   [3] => tags1
   [4] => tags2
   [5] => tags3
   [6] => tags4
   [7] => tags5
   [8] => tags6
   [9] => tags7
)

The index for each array is an ID which i would like o be part of the new array, so i would like it to look something like this:

Code:

Array
(
   [0] => Array
             (
                  [id] => 3
                  [title] => title1
                  [description] => description1
                  [tags] => tags1
             )
   [1] => Array
             (
                  [id] => 4
                  [title] => title2
                  [description] => description2
                  [tags] => tags2
             )
   [2] => Array
             (
                  [id] => 5
                  [title] => title3
                  [description] => description3
                  [tags] => tags3
             )
   [3] => Array
             (
                  [id] => 6
                  [title] => title4
                  [description] => description4
                  [tags] => tags4
             )
   [4] => Array
             (
                  [id] => 7
                  [title] => title5
                  [description] => description5
                  [tags] => tags5
             )
   [5] => Array
             (
                  [id] => 8
                  [title] => title6
                  [description] => description6
                  [tags] => tags6
             )
   [6] => Array
             (
                  [id] => 9
                  [title] => title7
                  [description] => description7
                  [tags] => tags7
             )
)

PHP would be nice, but I'm stuck on logic, not syntax, so anything that can help is great.

Thanks

-------
Anyone who isn't confused really doesn't understand the situation
http://craigk.org/pictures/
Can you work out the code?


6:33 pm on April 17, 2008 | Joined Feb. 2005 | 1020 Days Active
Join to learn more about pleaseremove England, United Kingdom | Straight Male | 5279 Posts | 28435 Points
Post from this position was omitted due to content violations
i who have nothing


Wealthy Hobo

Sustainer
Reply
You can use classes.  i.e.

Code:

class newClass {
public $id;
public $title;
public $descrip;

function __construct() {
//constructor code here
}
}

then create the array and populating it with instances of the class.

(i've never actually done this other than in C++ and Java but I'm assuming that using your sais of PHP syntax you could get it popping.)

Post edited at 11:28 am on April 25, 2008 by i who have nothing

-------
you can't stop what's comin. it ain't all waitin on you; that's vanity.


11:23 am on April 25, 2008 | Joined Mar. 2008 | 53 Days Active
Join to learn more about i who have nothing Ontario, Canada | Straight Male | 1442 Posts | 5893 Points
Single page for this topic Email Print Favorite

Quick Reply

You are signed in as our guest.

Looking for something else?
 

  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic