| | |
extract from a string
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Sep 2007
Posts: 48
Reputation:
Solved Threads: 1
I would like to take a string (I have loaded it from the database) and extract it into chunks.
The beginning string, lets call it "$string", has the following format:
(maybe more li's, maybe less, or even none)
What I would like to do is extract to an array each li, display each array element seperately ( with an option to "delete it"), then after add them back to the string and place back in the database. And yes I want each array element to include the li tags within(not that its necessary, I guess I could get around it)
I understand most of it, just getting hung up on how to extract each from the string and place into an array.
Anyone have an ideas how to go about this?
The beginning string, lets call it "$string", has the following format:
PHP Syntax (Toggle Plain Text)
<li>item1</li><li>item2</li><li>item3</li>
What I would like to do is extract to an array each li, display each array element seperately ( with an option to "delete it"), then after add them back to the string and place back in the database. And yes I want each array element to include the li tags within(not that its necessary, I guess I could get around it)
I understand most of it, just getting hung up on how to extract each from the string and place into an array.
Anyone have an ideas how to go about this?
Last edited by verbob; Nov 4th, 2009 at 5:49 pm.
0
#3 Nov 4th, 2009
An explode would be the quickest/easiest way to do this.
PHP Syntax (Toggle Plain Text)
$liArray = explode("</li>", $string); foreach($liArray as $key => $value) { // $value will contain the li string, do something with it here. }
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
0
#7 Nov 4th, 2009
Use array_pop to remove the last index from the array:
PHP Syntax (Toggle Plain Text)
$liArray = explode("</li>", $string); // $liArray_pop will contain the last index of $liArray, $liArray will be missing the final index $liArray_pop = array_pop($liArray);
Last edited by Will Gresham; Nov 4th, 2009 at 8:50 pm.
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
![]() |
Similar Threads
- extract data from a char string (C)
- Extract part of string (JavaScript / DHTML / AJAX)
- trying to use substr to extract data from a string of bytes, help would be great (C++)
- Extract a string (C++)
- Extract Words from a line in a .txt file (C++)
- Help with string (C)
Other Threads in the PHP Forum
- Previous Thread: Question about mass mail function
- Next Thread: PHP to display content in editable text area
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access action ajax apache api array auto beginner binary broken cakephp checkbox class cms code cron curl database date directory display domain download dynamic echo email error errorlog fatalerror file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link load login loop mail masterthesis menu mlm mod_rewrite multiple mysql oop parse paypal pdf php popup problem query radio random record recursion regex remote script search security server sessions sms soap source space sql structure syntax system table tutorial update upload url validation validator variable video web xml youtube





