SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    London
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    URL in Loop question

    Hey I am new to php and I can understand the basics with loops etc from other programming I have done but I dont know inbuilt functions or how you would actually go about getting data not inputted by the user or pulled out of a db. I am currently modding a script to work with a website I am making for a friend.

    I need the code for this if statment.

    If(url == www.site.cpm/folder/*){
    do this;
    }

    So something which grabs the url of the page on use regex to see if it is in www.site.cpm/folder/ if it is then i would put my loop functionality in.

    Thanks alot for any help you can give.

  2. #2
    SitePoint Member cumquott's Avatar
    Join Date
    Aug 2004
    Location
    Pennsylvania
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not really sure what you need...amongst this stuff could be what you need. Pay attention to the backslashes (read up on regular expressions perl style).

    <?php

    $cURL = "http://www.mysite.org/documents/my/stuff.html";

    if(preg_match("/www\.mysite\.org/", $cURL)) {
    print "It matched.";
    } else {
    print "It didn't match.";
    exit;
    }
    print "<p>";

    $cCleaned = preg_replace("/^http:\/\//", "", $cURL);

    print "$cURL<br>$cCleaned<p>";

    foreach(preg_split("/\//", $cCleaned) as $cTmp) {
    print "Do something with $cTmp<br>";
    }

    ?>


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
  •