regs?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yang Li Ke

    #1

    regs?

    Hi Guys!

    I need a way to convert a string like this:

    <select name="something ">
    <option value="1">var1</option>
    <option value="2">var2</option>
    <option value="3">var3</option>
    <option value="4">var4</option>
    </select>

    to this:

    something=[1,2,3,4]

    Anyone can help?
    --
    Yang


  • Pedro Graca

    #2
    Re: regs?

    Yang Li Ke wrote:[color=blue]
    > Hi Guys!
    >
    > I need a way to convert a string like this:
    >[/color]


    <?php
    $str = <<<STR[color=blue]
    > <select name="something ">
    > <option value="1">var1</option>
    > <option value="2">var2</option>
    > <option value="3">var3</option>
    > <option value="4">var4</option>
    > </select>[/color]
    STR;

    [color=blue]
    >
    > to this:
    >
    > something=[1,2,3,4][/color]


    $str2 = preg_replace('@ <select name="(\w*)">.* @s', '$1=[', $str);
    preg_match_all( '@<option value="(\d)">va r\d</option>@', $str, $values);
    $str2 .= implode(',', $values[1]) . ']';
    ?>


    --
    USENET would be a better place if everybody read: : mail address :
    http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
    http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
    http://www.expita.com/nomime.html : to 10K bytes :

    Comment

    Working...