Tenatious
Tenatious

Reputation: 889

Remove from a URL

So I have the following URL:

http://www.domain.com/Folder1/Folder2/file.php

Is there a way for me to just grab the http://www.domain.com/Folder1/ part?

Upvotes: 0

Views: 68

Answers (2)

vedarthk
vedarthk

Reputation: 1333

You can also use :

$url = 'http://www.example.com/path1/path2?googleguy=googley';

$array = preg_match('((http|https|ftp)://[a-zA-Z0-9\-\.]+/[a-zA-Z0-9\-]+/)', $url);

var_dump($array);

Upvotes: 1

Sumoanand
Sumoanand

Reputation: 8939

I would suggest this:

<?php
$url = 'http://www.example.com/path1/path2?googleguy=googley';
$array = parse_url($url)
var_dump($array);
var_dump( explode('/',$array["path"]));
?>

Upvotes: 2

Related Questions