| | |
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; 26 Days Ago at 5:49 pm.
0
#3 26 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 26 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; 26 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 |
apache api array beginner binary broken cache cakephp checkbox class cms code confirm cron curl customizableitems database date display dynamic echo email error external fcc file files folder form forms forum freelancing function functions google header headmethod howtowriteathesis href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction menu method mlm mod_rewrite multiple mysql neutrality oop pageing pagerank paypal pdf php phpmysql play problem query question radio random recursion remote root script search select server sessions sms soap source space sql support! syntax system table template tutorial update upload url validator variable video web youtube





