[PHP] Regex help appreciated
I am trying to get a regex to extract the Some and more text between the para elements below in a single pass for style attribute of heading 2 para font-size=12 font-family=Arial style=heading 2Someanchor type=bkmrk/more text-/para para font-size=12 font-family=Arial style=heading 2inline caps=falseSome text/inlinemore text/para Tried something like this for first bit but grabbing the anchor tag with the text. |para(.*)style=\heading 2\(([a-zA-Z0-9/-/_/\s]+)?)([anchor type=bkmrk name=[a-zA-Z0-9/_]+/])?(.*)/para| Help much appreciated. Thanx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Arrays of strings from regex
Am working through document to collect pieces that match and then insert them into an array so they can be used to construct another file. Looking in my doc for lines like this: {\*\cs43 \additive \sbasedon10 db_edition;} {\*\cs44 \additive \sbasedon10 db_editor;} {\*\cs45 \additive \sbasedon10 db_email;} Wrote this regex to find them: ^\{\\\*\\?(cs[0-9]{1,3}) (.*)\\[a-z0-9]+ (.*);\}$ Now looking for best method for getting the parts in parenthesis () into an array so it will contain these values by finding the above three lines: $matches [0][0][0] = cs43 , \additive \sbasedon10, db_edition $matches [1][1][1] = cs44 , \additive \sbasedon10, db_editor $matches [2][2][2] = cs45 , \additive \sbasedon10, db_email Thanks in advance for any pointers. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to obtain unique XML Elements
Anyone have a simple technique for obtaining a unique list of elements from an XML file? Am looking for something that will identify the first opening tag ie thistag and the single tag anothertag/ so that I get an array of tags that I can print out. Having a bit of trouble with regex to get something to work. Basic idea I had is to open file, read through each line with regex, add matches to array, and then do unique elements of array and write to another file. Is there a better way? -- Regards, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Ereg Help
Hi William, try this: ^(#[0-9]{2}-[0-9]{2,4} Item Description: [\$][0-9]{1,3}[\.][0-9]{2})$ I've just been putting a number of expressions together for validation myself. Regards, Dave Pratt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Record Sorting Using Up and Down Arrows
I'm hoping someone can help me solve this problem. I've almost got something working. Only problem is I am having some difficulty trying to come up with a case or condition for the single value (ie. devmodfile value = file 3 in example below) that it won't print any arrows up, up/down, or down. It's a bit of a puzzler and haven't added anything to the case. I have a print_r and a print with the variables so that anyone can see what is happening. I put a small array of test values in so that it can be run. The data will come from an SQL database but this is enough to test. Once this is working, I'll attach graphics and actions to the up and down arrows. The script is below: Thanks in advance for any help. Regards, Dave Pratt ?php $items[] = array(devfunctionid = 1, devmodfile = file1); $items[] = array(devfunctionid = 2, devmodfile = file1); $items[] = array(devfunctionid = 3, devmodfile = file1); $items[] = array(devfunctionid = 4, devmodfile = file2); $items[] = array(devfunctionid = 5, devmodfile = file2); $items[] = array(devfunctionid = 6, devmodfile = file3); $items[] = array(devfunctionid = 7, devmodfile = file4); $items[] = array(devfunctionid = 8, devmodfile = file4); foreach ($items as $item) { $devmodfile_values[] = $item['devmodfile']; } $rownum = 1; $numrows = count($items); $last_position = ''; foreach ($items as $item) { if (!isset($devmodfile_values[$rownum])) { $next_position = ''; } else { $next_position = $devmodfile_values[$rownum]; } $up = up arrow; $down = down arrow; switch($rownum) { case 1: if ($next_position != $item['devmodfile']) { $arrows = ''; } else { $arrows = $down; } break; case $numrows: if ($last_position != $item['devmodfile']) { $arrows = ''; } else { $arrows = $up; } break; default: if ($devmodfile_values[$rownum] != $item['devmodfile']) { $arrows = $up; } elseif ($item['devmodfile'] != $last_position) { $arrows = $down; } else { $arrows = $up $down; } break; } $rownum++; $last_position = $item['devmodfile']; print $arrows . --current file value: . $item['devmodfile'] . --last_position: . $last_position . --next_position: . $next_position . /br; } print /br/br; print_r($devmodfile_values); ?
[PHP] Record Sorting Using Up and Down Arrows
Hi there. I am trying to write a routine to allow me to sort the contents of a table by clicking on up or down arrows. The idea is that top record will have down arrow, bottom record up arrow and records inbetween both an up arrow and down arrow. Clicking the arrow causes the record to move up or down one row in the table. The hyperlinks on the arrows would be used to move the record up or down one by switching the sort order values in the records ie. you want to move a record one up, the value of the sort order would be switched with the record above. I have created a numeric sort field that I initialize with the same value and the id field in my table. I have my database content in an array that I want to use. So I want to create the table using an array of rows. I can get something basic to work if I do a count of my array to get the first and last value. I do a foreach and test the values in a switch like: switch($itemcount) { case 1: if ($itemtotal == 1) { $arrows = ''; } else { $arrows = $downarrow; } break; case $itemtotal: if ($itemtotal == 1) { $arrows = ''; } else { $arrows = $uparrow; } break; default: $arrows = $uparrow $downarrow; break; } The problem I am having is to come up with a way to make this work when there is more than one field to sort on. I have a table with a list of functions and files. There is a many to one relationship between functions and files and I want the up and down arrows to work for sorting the functions in the files in the list. So that if a file has say 4 functions the first would be down arrow, next two records would have both arrows, last record for file uparrow, next record down arrow if file is different etc. Could anyone help by giving me some advice on the best way of getting something like this to work or have an example to follow. This would be helpful. I have checked the archives first but could not find anything. Regards, DAve -- Dave Pratt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Storing script in database??
I am creating an application where it would be useful to write and store script in a field in a MySQL database and create a loop to process the array of the code contained in the field. Conceptually, I think it sounds reasonable but I am uncertain of what kind of process I could use to have the code in the field variable read properly within the loop. Somewhat analogous to an include in HTML. The file would be read as though a single script file though the included material has come from a text field. This would be really useful for me since the code could be modified in the database outside a smaller application without changing the files. Any ideas here on how I might do this from anyone that has attempted anything similar? I have set everything up but just can't figure out how to bring the script text in the field into the file properly. Help much appreciated. -- Dave Pratt [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Example safe use of eval()
I am trying to get code that I have saved as a string in a database to evaluate as code within a larger script with a loop. There are obvious security concerns with allowing users to input code into the field if it is not preprocessed before it is evaluated. The eval function appears to be the ticket with PHP 4 since it will return the results as well. Has anyone got an example of an appropriate preprocessing strategy and/or example of eval() being used this way? Thanks to those that replied to my original post. -- Dave Pratt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Example safe use of eval()
Thanks, Justin. I am really trying to figure something else out instead of eval. It is really too much of a security hole. I really appreciate the community to bounce ideas. Regards, Dave -- From: Justin French [EMAIL PROTECTED] To: David Pratt [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: Re: [PHP] Example safe use of eval() Date: Thu, Aug 1, 2002, 5:35 PM You can't really do much to make sure the execution of eval is safe, it's more than you have to trust the string that you're about to eval(). So, as long as you and your production team were the only ones who put the code into the strings or tables, and tested the code before hand, then 90% there. I'd suggest also reading all the user-contributed notes at http://php.net/eval too. Justin on 02/08/02 5:26 AM, David Pratt ([EMAIL PROTECTED]) wrote: I am trying to get code that I have saved as a string in a database to evaluate as code within a larger script with a loop. There are obvious security concerns with allowing users to input code into the field if it is not preprocessed before it is evaluated. The eval function appears to be the ticket with PHP 4 since it will return the results as well. Has anyone got an example of an appropriate preprocessing strategy and/or example of eval() being used this way? Thanks to those that replied to my original post. -- Dave Pratt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php