Jump to content

[SOLVED] Unknown Modifier 't'


BillyBoB

Recommended Posts

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>');
?>

Link to comment
https://forums.phpfreaks.com/topic/99834-solved-unknown-modifier-t/
Share on other sites

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?

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;" />

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.