Jump to content
xisto Community

Tom743

Members
  • Content Count

    6
  • Joined

  • Last visited

  1. If i have a word like c.........a......t (with the dots in) and i wanted to replace it with cat how would i do it. If i use <?php$patterns = "/c(*)a(*)t/";$replace = "cat";echo preg_replace($patterns, $replace, 'c.....a.........t');[/color][color="#000000"]?> then when i type something like "come and look at this" is also filtered. Is there any way just to filter cat with dots in?
  2. Ive got this small php script that makes the numbers count up. <?phpfor($num = 1; $num <= 10; $num++) {echo "Number: $num<br>";}?> Is there any way it can be changed so that the numbers count down? Thanks
  3. Ive got a problem with preg replace, this is the code: display.php <table border="1"><tr><th width="70">Time</th><th width="200">IP</th><th width="70">Viewed</th></tr><?php$LogData = file_get_contents("log.txt");$Find = "/||(.*)|(.*)|(.*)||/i";$Replace = "<tr><td>$1</td><td>$2</td><td>$3</td></tr>";$Table = preg_replace($Find, $Replace, $LogData);print "$Table";?></table> And this is whats in log.txt ||05-05-2008 12:08|127.0.0.1|1||||05-05-2008 12:00|127.0.0.1|1||||05-05-2008 12:00|127.0.0.1|1|| But it just displays like this. http://forums.xisto.com/no_longer_exists/ Its ment to display it so that each one has its own row and is devided into colums.
  4. Ok, but if im not just going to add a shoutbox code in there, i will post other tags like so then it wont work
  5. Is it possible when using PHP preg_replace, to include something, rather than displaying text. The code is below, the proplem is with the shoutbox. <?phpfunction code( $input ){$find[0] = "/\[b\](.*?)\[\/b\]/i";$find[1] = "/\[url\=(.*)\](.*)\[\/url\]/";$find[2] = "/\[u\](.*?)\[\/u\]/i";$find[3] = "/\[i\](.*?)\[\/i\]/i";$find[4] = "/\[big\](.*?)\[\/big\]/i";$find[5] = "/\[small\](.*?)\[\/small\]/i";$find[6] = "/\[shoutbox]id=(.*?)\[\/shoutbox\]/";$replace[0] = "<b>$1</b>";$replace[1] = "<a href=\"$1\">$2</a>";$replace[2] = "<u>$1</u>";$replace[3] = "<i>$1</i>";$replace[4] = "<font size=\"5\">$1</font>";$replace[5] = "<font size=\"2\">$1</font>";$replace[6] = include("shoutbox.php?no=$1");$change = preg_replace($find, $replace, $input);echo $change;}code("[shoutbox]id=2[/shoutbox]");?> It doesnt replace the $1 with the shoutbox id and the error message is; Notice from jlhaslip: Moved to PHP Programming Notice from truefusion: Merging topics
  6. <?phpfunction code( $input ){$data[0] = "<?php include(\"shoutbox.php?no=";$data[1] = "\"); ?>";$find[0] = "/\[b\](.*?)\[\/b\]/i";$find[1] = "/\[url\=(.*)\](.*)\[\/url\]/";$find[2] = "/\[u\](.*?)\[\/u\]/i";$find[3] = "/\[i\](.*?)\[\/i\]/i";$find[4] = "/\[big\](.*?)\[\/big\]/i";$find[5] = "/\[small\](.*?)\[\/small\]/i";$find[6] = "/\[shoutbox]id=(.*)\[\/shoutbox\]/";$replace[0] = "<b>$1</b>";$replace[1] = "<a href=\"$1\">$2</a>";$replace[2] = "<u>$1</u>";$replace[3] = "<i>$1</i>";$replace[4] = "<font size=\"5\">$1</font>";$replace[5] = "<font size=\"2\">$1</font>";$replace[6] = "$data[0]$1$data[1]";$change = preg_replace($find, $replace, $input);print $change;}code("[shoutbox]id=1[/shoutbox]");?> In my code, the shoutbox doesnt work. The code is ment to replace [shoutbox]no= with <?php include("shoutbox.php?no= then replace [/shoutbox] with "); ?> which it does, but then the php code just appears in the sorce of the webpage. Does anyone know how to fix it? Thanks Notice from electriic ink: There's no need to sign your name. We can see who started the topic
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.