SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation How to replace some words,numbers,characters

    In my database many posts has some characters like :

    [media id=468 width=660 height=440]

    With php i want to get media id (the number) and replace it with another function, also after taking the id, dont want that [media id=468 width=660 height=440] to be shown at my posts in html.

    Please can some one help with this ? Thank you a lot

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,197
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    See how this goes for you

    PHP Code:
    $replace     '[media id=468 width=660 height=440]';
    $replacement preg_replace('/id\=([0-9]+)/i'''$replace);

    echo 
    'Original: ' $replace '<br>Replaced: ' $replacement

  3. #3
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,197
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    No problem, glad to help


Tags for this Thread

Bookmarks

Posting Permissions

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