PHP removing string in URL's source

Posted on 2012-09-08
Last Modified: 2012-09-08

i am currently making a script  which is stripping some data off an internet site. Now one of the lines are troubling me and those are the ones with current date in it.

I am sure i could strip those too with some universal command but i am not sure which one.

So string look like this:  <report date="2012-08-31" valid="2012-09-01">

I need to remove whole string and not just dates in it.

Thank you!
Question by:Caruso_eu
    LVL 10

    Accepted Solution

    Can you be a bit more specific.

    If the line is static, with a fixed dated, you can use str_replace to remove parts of a string. If it is dynamic, you can use preg_replace
    $newstring = preg_replace('/<report date="\d\d\d\d-\d\d-\d\d" valid="\d\d\d\d-\d\d-\d\d">/', '', $oldstring);

    Open in new window


    Author Comment

    Exactly what i needed!

    Thank you!
    LVL 107

    Expert Comment

    by:Ray Paseur
    Please post the URL of the internet site so we can see the source that you want to strip.  Then we can give you a tested code sample.

    You can probably use this function:

    Author Comment

    Ray_Paseur : Thank you but solution to my problem was posted already!

    Thank you!

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
    Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now