473,659 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Jul 17 '05 #1
1 1610
Yang Li Ke wrote:
Hi Guys!

I need a way to convert a string like this:
<?php
$str = <<<STR <select name="something ">
<option value="1">var1</option>
<option value="2">var2</option>
<option value="3">var3</option>
<option value="4">var4</option>
</select> STR;


to this:

something=[1,2,3,4]

$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 :
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1214
by: Yannick Benoit | last post by:
Hi! I use this to find all links in a page : *(href)*=*(+) but recently i found out that it only works if links are setup this way: <a href = "... I would like to know if someone can help me find the proper expression which would work with <a href = "... <a href= "... <a href="... and <a href ="...
19
5853
by: Lorenzo J. Lucchini | last post by:
My code contains this declaration: : typedef union { : word Word; : struct { : byte Low; : byte High; : } Bytes; : } reg;
5
8177
by: rahul8143 | last post by:
hello, I want to know for what purpose union REGS and struct SREGS are used in windows programming? also how following code an determine that running OS is windows? in_regs.x.ax = 0x160A; int86x(0x2F, &in_regs, &out_regs, &seg_regs); if (out_regs.x.ax == 0) Running_WIN=TRUE; provided here union REGS in_regs, out_regs;
4
7251
by: Bruno Barros | last post by:
Hello, I don´t know if union REGS <dos.h> is part of this group, but i have a problem. At the moment i use turboc++lite and i don´t have reply when i execute the question code. Only a black screen! Anyone help me? What´s is wrong? This code return the DOS version. #include <stdio.h> #include <dos.h> #include <conio.h> //use getch() e clrscr()
5
9647
by: kushmanr | last post by:
hi i am having to problems: interrupt decleration doesn`t compile: void _interrupt _far terminal_isr() ....... _dos_setvect(0xC,terminal_isr) : error C4226: nonstandard extension used : '_far' is an obsolete keyword : error C2061: syntax error : identifier 'terminal_isr'
0
2529
by: balajiv86 | last post by:
hi can anyone tell me the book which contains details abt inbuilt union regs in c
0
5841
by: chikas | last post by:
hallo all,I need help and any tips shall be appreciated! i want to implement a I2C API(from Beck SC12 microcontroller) in a 1 wire search C-code(use to search devices on 1 wire bus) sothat that i can use Beck SC12 microcontroller to perform a 1 wire search command. I tried to implement this I2C API in the search code but my programm this not workout because my programming power is weak 1) see communication diagram on page one under:...
1
1530
by: Marcpp | last post by:
Hi, I need add to a listbox a list of items extracted from a database. This is that I've do: class tasques(wx.Frame): def __init__(self, *args, **kwds): ..... self.list_box_1_copy = wx.ListBox(self, -1, choices=, style=wx.LB_SINGLE|wx.LB_ALWAYS_SB) ....
3
2026
by: vicky | last post by:
Hi, i am vikram Please tell me the usage of REGS key word how it can be used? any kind of suggestions will help me.
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8539
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7360
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2759
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.