for each list list

Discussion in 'Web Design and Development' started by jlewis2k1, Dec 2, 2008.

  1. jlewis2k1 macrumors 6502a

    jlewis2k1

    Joined:
    Jan 14, 2005
    Location:
    in your closet
    #1
    In my SQL database I have a field that has a value as:
    Code:
    1000, 1013
    This is the code I have:
    PHP:
    function SentTo($list)
    {
        
    $arr = array($list);
        while (list(
    $value) = each($arr))
        {
            
    $who=GetUIDMessages($value);
            echo 
    $who;
            echo 
    "<br>";
        }

    }
    What I want to do is some how get the small list of IDs to return it's real name.

    So, for an example, if someone sends a message to 3 people and in that field it will show: 1012, 1010, 1002 and when you view the message i want to be able to return the actual name of the IDs that were inserted. To do this I have a small function that takes that list (shown above) and request the names of the IDs using GetUIDMessages($value) function. Is there a way to do this? Thanks for your help in an advance!
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    See if this gets you what you want.
    PHP:
    function SentTo($list)
    {
        
    $arr preg_split('/[\s,]+/'$list);
        for (
    $a=0$a count($arr); $a++)
        {
            
    $who=GetUIDMessages($arr[$a]);
            echo 
    $who;
            echo 
    "<br>";
        }
    }
     
  3. jlewis2k1 thread starter macrumors 6502a

    jlewis2k1

    Joined:
    Jan 14, 2005
    Location:
    in your closet
    #3
    Thanks buddy! *high fives ya*
     
  4. jlewis2k1 thread starter macrumors 6502a

    jlewis2k1

    Joined:
    Jan 14, 2005
    Location:
    in your closet

Share This Page