Connecting Tech Pros Worldwide Help | Site Map

regs?

  #1  
Old July 17th, 2005, 05:20 AM
Yang Li Ke
Guest
 
Posts: n/a
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


  #2  
Old July 17th, 2005, 05:21 AM
Pedro Graca
Guest
 
Posts: n/a

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)">var\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 :
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the word REGS meant...? vicky answers 3 June 25th, 2007 08:55 PM
problems with interrupts and union regs kushmanr answers 5 March 7th, 2007 10:17 PM
union REGS donīt get DOS Version Bruno Barros answers 4 February 7th, 2006 08:45 PM
what are REGS,SREGS ? rahul8143@gmail.com answers 5 November 15th, 2005 04:00 AM
need help with a regs expression Yannick Benoit answers 2 September 18th, 2005 10:05 AM