Hi. I'm working with data similar to the data inputted by users on a forum.
Just like you can use QUOTE tags and all that jazz on VBB forums, I want to be able to check for the existence of data that conform to the following to the following:
<cN integer>randomText</cN>
'integer' represents where a positive integer is required and 'randomText' represents where text is required.
The following is an example:
<cN 2>asdf</cN>
I need a regular expression that replaces these snippets of code with appropriate HTML.
Here is what I wrote but it doesn't seem to work.
for($e=0; $e<$cN->numEntries; $e++){
$cal->data[$i]=eregi_replace("\[cN\s".$e."]\[]*\[/cN]","<a href='javascript:cNLink(".$e.", \1)'>\1</a>",$cal->data[$i]);
}
Using the for loop lets me control the range of valid snippets of code. I saw an example where \1 was used to get a value that was matched to a part of a regular expression, which is what I need to appropriately form a html link.
However, it does not work. I'm using PHP 4 on WinXP with PHP Triad.
Thanks
~james