how do i separate a string?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • namemattersnot@msn.com

    how do i separate a string?

    re,

    $a = "&key1=val2&key 2=val2&key3=val 3"'

    how do I make the following array out of $a:

    array['values']['key1']
    ['key2']
    ['key3']

    thanks in advance!

  • J2be

    #2
    Re: how do i separate a string?


    <namemattersnot @msn.com> wrote in message
    news:1138769405 .939967.34680@z 14g2000cwz.goog legroups.com...[color=blue]
    > re,
    >
    > $a = "&key1=val2&key 2=val2&key3=val 3"'
    > how do I make the following array out of $a:
    >
    > array['values']['key1']
    > ['key2']
    > ['key3'][/color]


    <?php

    $a = "&key1=val2&key 2=val2&key3=val 3";

    $tmpar = split('&',$a);

    foreach($tmpar as $tmpval)
    {
    if($tmpval != '')
    {
    $tmpkval = split('=',$tmpv al);
    $aarray['values'][$tmpkval[0]] = $tmpkval[1];
    }
    }

    print_r($aarray );

    ?>




    Cheers


    --
    ----
    Leonardo Armando Iarrusso - J2Be
    www: http://www.J2be.com - e-mail: info[at]J2Be.com


    Comment

    • namemattersnot@msn.com

      #3
      Re: how do i separate a string?

      thank you!

      Comment

      Working...