| | |
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: 45
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; 23 Days Ago at 5:49 pm.
0
#3 23 Days Ago
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 23 Days Ago
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; 23 Days Ago 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 |
.htaccess access alexa apache api array beginner binary broken cakephp checkbox class cms code convert cron curl database date directory display dropdown dynamic echo email encode error fairness file files folder form forms function functions google hack href htaccess html htmlspecialchars image include indentedsubcategory insert ip javascript joomla limit link login mail mail() menu methods mlm multiple multipletables mysql network newsletters object oop passwords paypal pdf php problem provider query radio random recursion redirect remote script search secure securephp server sessions simple sms source space sql syntax system table tutorial update upload url user validator variable video voteup web youtube





