SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2002
    Location
    Hamburg
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Split an array into two ..

    Hi there,
    my problem is:
    I have an array for example like this:
    PHP Code:
    $asda=array("0/a""2/c""5/a"); 


    Now I want php to create two arrays like this:
    PHP Code:
    $one=("0","2","5");
    $two=("a","c","a"); 


    Could anybody tell me how to do this?
    Cheers,
    Karsten

  2. #2
    SitePoint Evangelist
    Join Date
    Nov 2001
    Location
    UK
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $one = array();
    $two = array();
    foreach(
    $asda AS $key => $val)
    {
     
    $exploded = array();
     
    $exploded explode("/"$val);
     
    $one[] = $exploded[0];
     
    $two[] = $exploded[1];

    That should work. Untested though.
    Regards, Ant.

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2002
    Location
    Hamburg
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank very much for the quick reply!

    Best wishes,
    Karsten

  4. #4
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $asda 
    Shop at asda's do we ?

  5. #5
    SitePoint Evangelist
    Join Date
    Nov 2001
    Location
    UK
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston
    Shop at asda's do we ? [img]images/smilies/biggrin.gif[/img] [img]images/smilies/FRlol.gif[/img]
    lol, I never noticed that. Perhaps exploding Asda isn't such a good idea then
    Regards, Ant.

  6. #6
    SitePoint Enthusiast
    Join Date
    Sep 2002
    Location
    Hamburg
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes,
    I'm from germany but everytime I visit a friend
    living in Derby I go to ASDA, and ASDA rocks =)

  7. #7
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Asda's explode ? Hope not Where else am I meant to shop... Not at Tesco I hope


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
  •