BillyBoB Posted April 6, 2008 Share Posted April 6, 2008 I am creating a widget maker class and when I try to select a certain part of the coding it gives me: Warning: preg_match() [function.preg-match]: Unknown modifier 't' in /var/www/html/testing.php on line 22 Line 22: <?php preg_match($this->preg, $this->fileinfo, $this->matches); ?> Whole Function: <?php function redefineContents($tags1,$tags2='') { if($tags2=='') { //self-destructing tag $this->tag1 = addslashes($tags1); }else{ $this->matches = array(); $this->tag1 = addslashes($tags1); $this->tag2 = addslashes($tags2); $this->preg = "/".$this->tag1."(.*?)".$this->tag2."/is"; preg_match($this->preg, $this->fileinfo, $this->matches); } } ?> Bottom Call to function: <?php $bungie=new Widget(); $bungie->getContents("http://www.bungie.net/Stats/Halo3/Default.aspx?player=Lovely%20Coconuts"); $bungie->redefineContents('<a id="ctl00_mainContent_identityStrip_hypGamerTag" href="/Stats/Halo3/Default.aspx?player=Lovely Coconuts">','</a>'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/99834-solved-unknown-modifier-t/ Share on other sites More sharing options...
Daniel0 Posted April 6, 2008 Share Posted April 6, 2008 It's because the string contains forward slashes which is what you're using as delimiter in the regular expression. You could do addcslashes($string, '/'); to fix that. Quote Link to comment https://forums.phpfreaks.com/topic/99834-solved-unknown-modifier-t/#findComment-510603 Share on other sites More sharing options...
BillyBoB Posted April 6, 2008 Author Share Posted April 6, 2008 Thanks for that but one more question. When I try to print_r the $this->matches it is telling me: Parse error: syntax error, unexpected T_VARIABLE in /var/www/html/testing.php on line 33 But when I try to echo it it tells me that it is an array??? Would you rather talking on AIM or MSN? Quote Link to comment https://forums.phpfreaks.com/topic/99834-solved-unknown-modifier-t/#findComment-510611 Share on other sites More sharing options...
trq Posted April 6, 2008 Share Posted April 6, 2008 Would you rather talking on AIM or MSN? Defeats the purpose of the board somewhat doesn't it? Post your code. Quote Link to comment https://forums.phpfreaks.com/topic/99834-solved-unknown-modifier-t/#findComment-510637 Share on other sites More sharing options...
BillyBoB Posted April 6, 2008 Author Share Posted April 6, 2008 Im trying some new things but here is what I have now. <?php class Widget { var $fileinfo = ''; var $tag1 = ''; var $tag2 = ''; var $matches = ''; var $preg = ''; function getContents($filename) { $this->fileinfo = file_get_contents($filename); } function redefineContents($tags1,$tags2='') { if($tags2=='') { //self-destructing tag $this->tag1 = addslashes($tags1); }else{ $this->matches = array(); $this->tag1 = addslashes($tags1); $this->tag1 = addcslashes($this->tag1, '/'); $this->tag2 = addslashes($tags2); $this->tag2 = addcslashes($this->tag2, '/'); $this->preg = "/".$this->tag1."(.*?)".$this->tag2."/is"; preg_match($this->preg, $this->fileinfo, $this->matches); } } } $bungie=new Widget(); $bungie->getContents("http://www.bungie.net/Stats/Halo3/Default.aspx?player=Lovely%20Coconuts"); $bungie->redefineContents('<a id="ctl00_mainContent_identityStrip_hypGamerTag" href="/Stats/Halo3/Default.aspx?player=Lovely Coconuts">','</a>'); if($bungie->matches == '') { echo "Null2"; } echo count($bungie->matches); for ($i=0; $i < count($bungie->matches); $i++) { $tag = $bungie->matches['0'][$i]; $text = $bungie->matches['2'][$i]; echo $tag . " -- " . $text . "</br>"; } ?> It is currently echoing back '0' from the count($bungie->matches). The outcome I'm looking for is in the tags that I have used which would be <img id="ctl00_mainContent_identityStrip_EmblemCtrl_imgEmblem" src="/Stats/halo2emblem.ashx?s=70&0=18&1=2&2=3&3=0&fi=68&bi=19&fl=1&m=1" style="height:70px;width:70px;border-width:0px;" /> Quote Link to comment https://forums.phpfreaks.com/topic/99834-solved-unknown-modifier-t/#findComment-510645 Share on other sites More sharing options...
Daniel0 Posted April 6, 2008 Share Posted April 6, 2008 What's wrong with that code? Quote Link to comment https://forums.phpfreaks.com/topic/99834-solved-unknown-modifier-t/#findComment-510646 Share on other sites More sharing options...
BillyBoB Posted April 6, 2008 Author Share Posted April 6, 2008 Reread what I just edited. The outcome I'm looking for isn't coming up. Quote Link to comment https://forums.phpfreaks.com/topic/99834-solved-unknown-modifier-t/#findComment-510648 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.