| | |
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; 28 Days Ago at 5:49 pm.
0
#3 28 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 28 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; 28 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 beneath binary broadband broken button cakephp checkbox class cms code countingeverycharactersfromastring crack cron curl database date decode display dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip javascript joomla limit link links login mail match md5 menu mlm multiple mysql mysql_real_escape_string oop paypal pdf php problem protocol query radio random recursion regex remote script search searchbox server session sessions sms smtp soap source space sql strip_tags survey syntax system table tutorial undefined update upload url validator variable video virus votedown web website window.onbeforeunload=closeme; xml youtube





