Jump to content

gdfhghjdfghgfhf

Members
  • Posts

    218
  • Joined

  • Last visited

Posts posted by gdfhghjdfghgfhf

  1. Have a look at preg_replace(),

    http://uk3.php.net/manual/en/function.preg-replace.php

     

    An expression like this should suffice (from :

    // Regex taken from: http://flanders.co.nz/2009/11/08/a-good-url-regular-expression-repost/
    $regex = "/(?#Protocol)(??:ht|f)tp(?:s?)\:\/\/|~\/|\/)?(?#Username:Password)(?:\w+:\w+@)?(?#Subdomains)(??:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\d]{1,5})?(?#Directories)(??:(?:\/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|\/)+|\?|\#)?(?#Query)(??:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?#Anchor)(?:\#(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)?/";
    $newdata = preg_replace($regex,"(link)",$data);
    
    // Where $data is your content you want to replace links for

     

    -cb-

     

     

    Have you even tried this script i put together for you?

    It does exactly what you want.

     

    -cb-

     

    i have a problem with this script

     

    for example, this text:

    [DL]http://www.megaupload.com/?d=QI29F7AJ[/DL]

     

    maxi  repressage de 1982

     

    01 - couleurs sur paris.mp3

    02 - maximum.mp3

    03 - tout ce fric.mp3

    04 - poupee de cire.mp3

    05 - piano dub.mp3

    AlbumArtSmall.jpg

    Folder.jpg

    OBERKAMPF-LP-Couleurs5tvert.jpg

     

    will turn into:

    [DL](link)[/DL]

     

    maxi  repressage de 1982

     

    (link)3

    (link)3

    (link)3

    (link)3

    (link)3

    AlbumArtSmall.jpg

    Folder.jpg

    OBERKAMPF-LP-Couleurs5tvert.jpg

     

    i want to convert only the links that start with http://

     

    but the script thinks the list of the mp3 names are links

     

    any help would be appreciated!

  2. i want to shorten only the big words, not to shorten a whole string

     

    example:

     

    "this is a text with small words and a big word like " anticonstitutionally " and i want to shorten words that exceed 10 characters"

     

    would result in

     

    "this is a text with small words and a big word like " anticonsti" and i want to shorten words that exceed 10 characters"

  3. Hi,

     

    I ran the script and it worked perfectly.

     

    $url = "http://www.link.com This is a test and hello my name is bob";
    $result = xcleaner($url);
    
    print $result;
    
    
    function xcleaner($url) {
    
       $U = explode(' ', $url);
    
       $W =array();
       foreach ($U as $k => $u) 
          {
          $W = explode('.', $u);
          if (stristr($u,'http') || (count($W) > 1 && $W[1] != "") || (count($W) > 2))
             {
             unset($U[$k]);
             return implode(' ',$U);
             }
          }
       return implode(' ',$U);
       }
    

     

     

     

    yes you are right... i just realized the given example will work

     

    but if i try with this text it will not work:

     

    http://www.dailymotion.com/video/x4o...me-french_news

     

    http://www.dailymotion.com/video/x4o...french-p2_news

     

    http://www.dailymotion.com/video/x4o...french-p3_news

     

    http://www.dailymotion.com/video/x4o...french-p4_news

     

    http://www.dailymotion.com/video/x4s...french-p5_news

     

     

    Super Size Me est un film documentaire américain réalisé par Morgan Spurlock. Le journaliste décide de se nourrir exclusivement chez McDonald’s pendant un mois et enquête à travers les États-Unis sur les effets néfastes du fast-food et de la célèbre chaîne spécialiste du hamburger, qui entraînent l'accroissement de l'obésité.

     

    i don't understand where the problem comes from..

     

    ungovernable,

     

    If I understand your request correctly, the following code produces what you want:

     

     

     

    link hello my name is bob

     

    http://link.com hello my name is bob

     

    actually, i want to replace ALL links with the text "link"

     

    so something like

     

    http://www.awebsite.com/hello/blabla/hi.php would be replaced by "link"

  4. hello,

     

    i am using this script to remove links in a text:

     

    function xcleaner($url)

      {

      $U = explode(' ', $url);

     

      $W =array();

      foreach ($U as $k => $u)

          {

          $W = explode('.', $u);

          if (stristr($u,'http') || (count($W) > 1 && $W[1] != "") || (count($W) > 2))

            {

            unset($U[$k]);

            return implode(' ',$U);

            }

          }

      return implode(' ',$U);

      }

     

    the problem is that it will also remove the first word after the link

     

    example:

    http://www.link.com hello my name is bob

     

    would result in:

    my name is bob

     

    how can i fix this ?

     

     

    also, i would like to replace the links with the word "(link)" instead of just removing everything

     

    thanks a lot!

  5. ok so here is my situation:

     

    i have a t-shirt shop at spreadshirt.com, but it is in french

     

    i'm trying to translate the main page in english

     

    so i use file_get_contents() to display the page, and then i use str_replace() to translate the words

     

    i can translate all the words but when i try to replace a word with accents it doesn't work...

     

    how to solve this problem ?

  6. Well i'm looking to do something i usually could do easily using COUNT and GROUP BY if it was a sql query... But this time i'm working with an array...

     

    so i have an array that looks like this

     

    $array(
    "dog",
    "cat",
    "dog",
    "fish",
    "horse",
    "cat",
    );

     

    First i want to group together the duplicate entries. And then, i want to list the number of times the item was found in the array

     

    with the above example, i would be expecting a result like this:

    $array(
    "dog (2 results)",
    "cat (2 results)",
    "fish (1 results)",
    "horse (1 results)",
    );

     

    From what i have read on google i can group together the duplicate entry with array_unique() but i have no idea how i can list the number of times this item was found in the array

     

    thanks for helping me!!

  7. Damn, sorry

     

    here is the query with the GROUP BY request

     

    $query = "SELECT search_time, search_keywords FROM phpbb_popsearch GROUP BY search_keywords ORDER BY search_time DESC limit 35";

     

    So it will group together entries with the same name, but it will lose its original position ! (i.e. first entries will not be first anymore once its grouped)

  8. i usually use this query to display the last 10 entries from a sql table:

     

    $query = "SELECT search_time, search_keywords FROM phpbb_popsearch ORDER BY search_time DESC limit 35"; 

     

    as you can see it will order the results by "search_time" so the latest entries are listed first

     

    normally the result would be something like this:

    new entry

    duplicate

    another entry

    bla bla

    348237

    543543

    duplicate

     

    but now i just want to include a "GROUP BY" in this sql request

    $query = "SELECT search_time, search_keywords FROM phpbb_popsearch ORDER BY search_time DESC limit 35"; 

     

    but with the GROUP BY my sql query isn't ordered correctly anymore.

     

    the result would be something like this:

    new entry

    another entry

    bla bla

    348237

    543543

    duplicate

    notice the "duplicate" entry was grouped together, but it's not in the second first position anymore ???

     

    i was expecting a result like this:

    new entry

    duplicate

    another entry

    bla bla

    348237

    543543

    Since entry called "duplicate" is the second last added entry....

     

    i hope you understand what i mean ^^

     

    thanks for help

  9. ok so i have this very simple code:

    $query = "SELECT search_keywords, COUNT(search_keywords) AS counter FROM phpbb_popsearch GROUP BY search_keywords ORDER BY counter DESC limit 5"; 
    $res = mysql_query($query) or die(mysql_error());   
    
    while($row = mysql_fetch_array($res)) { 
    $term = $row["search_keywords"];
    echo $term;
    }
    

     

    phpbb_popsearch is a table where i put the last search terms used in my forum search engine

     

    this code will group together the same terms and list the 5 most popular terms

     

    my problem is that the results will be ordered by "counter" which is the number of time a term has been found.

     

    I want to get the 5 most popular results AND THEN, AFTER, list the results alphabetically

     

    if i sort the results alphabetically right in the sql query (replacing "ORDER BY counter" by "ORDER BY search_keywords") it will not work correctly because it will not get the 5 most popular terms but just the 5 first terms, alphabetically sorting them and ignoring the number of times the term has been found

     

    thanks for help !!

  10. i think you didn't understand what i want to do

     

    i want to make a script that i can access just like anonym.to

     

     

    and if i access this URL, then it will display some text and redirect 5 seconds after

     

    my only problem is that i can't use $_GET because the limit is 100 characters :(

     

  11. Ok basically what i want to do it a redirection system with a temporary page.....

     

    just like anonym.to

     

    if you go to

    http://anonym.to/http://www.phpfreaks.com it will display a temporary page then redirect you to phpfreaks.com

     

    normally i would just do that with $_get but the damn limit of characters is only 100, so it will not work with long URL

     

    how exactly is anonym.to working ? It looks like a htaccess redirect, but how can you transmit values through htaccess then take back this value in your php code just like $_GET does

     

    any suggestions?

     

    btw i want to avoid using $_POST if possible...

  12. That example isn't matched by the pattern. Your pattern requires a space after the closing double bracket, which there isn't in the example.

    Damn, i'm an idiot! I didn,t pay attention to the space.

     

    Thanks a lot

     

    Oh and how about stop converting <a href=""></a> to

     

    would it be very hard??

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