Jump to content

Invincible

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Invincible's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Invincible

    Time

    I believe it stores the posted time in SQL. You would need to send $time_posted to a database, then have it pull it out. $time_now can obviously be done with date function
  2. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]put the pattern in an array[/quote] How? [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Manual: [a href=\"http://no.php.net/manual/en/function.preg-replace.php\" target=\"_blank\"]http://no.php.net/manual/en/function.preg-replace.php[/a][/quote] Broken link, however I have had a look at the example for preg_replace and they are using an array which is exactly what I am doing and their's works fine. Please could you just post what I would need to do for the code I ahve laid out (it is a very simple code)and I will suss how this works. Thanks
  3. Hello, I am using this simple preg_replace function to turn "Google" into a linkt o the Google site (not really what I am using it for I am just using it as an example) [code] $txt = preg_replace( "#Google#is", "<a href='http://www.google.com/'>Google</a>", $txt ); [/code] But what about if I want to link Yahoo, well the simple option would be to just repeat the line. However, what if I start adding in MSN, Alta Vista, it will all get very confusing, so I create an array. The array setting the words: [code] array( "Google", "Yahoo", "MSN" ); [/code] And the array with the links: [code] array( "<a href='http://www.google.com/'>Google</a>", "<a href='http://www.yahoo.com/'>Yahoo</a>", "<a href='http://www.msn.com/'>MSN</a>" );[/code] Alternativly, we could have this: [code] array( "Google"  =>  "<a href='http://www.google.com/'>Google</a>", "Yahoo"  =>  "<a href='http://www.yahoo.com/'>Yahoo</a>", "MSN"  =>  "<a href='http://www.msn.com/'>MSN</a>" ); [/code] But how do I now get this to work!? My itnitial thought was this: [code]<?php $names = array( "Google", "Yahoo", "MSN" ); $links = array( "<a href='http://www.google.com/'>Google</a>", "<a href='http://www.yahoo.com/'>Yahoo</a>", "<a href='http://www.msn.com/'>MSN</a>" ); $txt = preg_replace( "#".$names."#is", $links, $txt ); ?>[/code] However, this of course, did not worsk, and I was produced with this error: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] Warning: preg_replace(): Parameter mismatch, pattern is a string while replacement in an array. in /home/****/public_html/forums/keywords.php on line 15[/quote] So my question is, how do I enable arrays in preg_replace!? Thanks in adavcne for your help, Mark
×
×
  • 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.