boeing
boeing

Reputation: 302

Adding prefix to url for use with PHP CURL function

I'm trying to get some data from a website using PHP Curl as follows:-

$url_1 = "website.com"
$url_2 = "http://www.website.com"
$url_3 = "http://www." . $url_1;

$ch = curl_init($url_1);       // failure
$ch = curl_init($url_2);       // success
$ch = curl_init($url_3);       // failure

I have a huge list of URLS in the format of $url_1 please will you let me know how I can add the http:// prefix to the url so it can be accepted by curl_init()

Thanks

Upvotes: 0

Views: 385

Answers (1)

jameslafferty
jameslafferty

Reputation: 2182

Try $ch = curl_init("http://www." . trim($url_1));

Upvotes: 1

Related Questions