Results 1 to 3 of 3

Thread: Replace strings

  1. #1
    Join Date
    Feb 2004
    Posts
    9

    Unanswered: Replace strings

    I have a MySQL database system and their is a table to store the abbreviation of some words.

    e.g.
    abbreviation original
    -------------- --------
    HK Hong Kong
    NY New York


    I would like to replace the abbreviation with the orginal words when I input some sentences

    e.g.
    I come from HK and I want to go to NY. --> I come from Hong Kong and I want to go to New York.

    My idea is that:
    1. First, people will fill in the discription of something using form.
    2. Then, A php file will collect this discription and search if these paragraph contains the abbreviation in my database.
    3. IF some words match, the abbreviation will be replaced with longer words in my database.

    ***What did the user fill in will be different every time.
    Last edited by barry_1030; 02-19-04 at 06:58.

  2. #2
    Join Date
    Jan 2004
    Location
    Aberdeen
    Posts
    12
    $string = "I come from HK and I want to go to NY.";

    $abrv = "HK";
    $fullname = "Hong Kong";

    $string = ereg_replace($abrv, $fullname, $string);

  3. #3
    Join Date
    Jan 2004
    Location
    Aberdeen
    Posts
    12
    Oh,

    you can double check the syntax at

    http://uk.php.net/manual/en/function.ereg-replace.php

    cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •