SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    This has been busting my brains for about 4 hours now and I can't get my head round it although it should be quite simple.

    I have an organised set of data held in a string.
    In simple terms this is what I'm trying to do.

    Heres a simplified example of the string.

    <br>
    A1
    B1
    C1
    <br>
    A2
    B2
    C2
    <br>
    A3
    B3
    C3
    <br>

    Now I need to take the sring and get it to:

    $something . A1 . $Something
    $something . A2 . $Something
    $something . A3 . $Something
    $something . B1 . $Something
    $something . B2 . $Something
    $something . B3 . $Something
    $something . C1 . $Something
    $something . C2 . $Something
    $something . C3 . $Something


    I believe all in needs is a for() within another for() but it is absolutly driving me made.

    Serious mental block!!

    Cheers for the help.

  2. #2
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Let me try if I understand what you wanna do

    Code:
    $ary = explode("<br>",$input);
    for ($i=0;$i<count($ary);$i++)
    { $ary[$i] = explode("\n",$ary[$i]); 
    }
    
    for ($i=0;$i<count($ary);$i++)
    { echo("Somthing ".$ary[$i][$i]." Something Else");
    }
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  3. #3
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers for the help, I'll see if I can get it to work!

  4. #4
    SitePoint Evangelist
    Join Date
    May 2000
    Location
    Canada
    Posts
    533
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $ary ? .. hehe, cute ! .. i use things like $tempArray .. hehe
    cogito, ergo sum

  5. #5
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Thanks for the help - finally got a solution that worked.

    Just one thing: -

    Can you explain the '$ary[$i][$i]'

    I've only ever come across the single[] never the double[][].

  6. #6
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ChiliBoy: that's a multi-dimensional array, it allows you to store another "level" of data so to speak. Here's some more information:

    http://www.php.net/manual/en/ref.array.php

  7. #7
    Bored One boredboi's Avatar
    Join Date
    Jul 2000
    Posts
    238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    one question:

    is ary[$i][$j]
    the same as ary[$i] = array($j=>""); ?

  8. #8
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by boredboi
    one question:

    is ary[$i][$j]
    the same as ary[$i] = array($j=>""); ?
    Yes, they're equivalent.

    You could even go deeper and deeper ("array layers")
    array[3][2][1][2][2].....
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy


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
  •