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
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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.