tags:

views:

44

answers:

2

Hello friends.

I have one problem regarding CURL. I am trying send CURL request to http://whatismyipaddress.com

so.. is there any way to get curl response in array ? because right now it display the HTML Page but i want the response in array.

here is my code...

$ipAdd = '121.101.152.170';
$ch = curl_init("http://whatismyipaddress.com/ip/".$ipAdd);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION  ,1);
curl_setopt($ch, CURLOPT_HEADER,0);  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);      
curl_close($ch);
echo $output;

So.. currently i am getting the detail HTML page but i want the out put as array or XML.

+3  A: 

The "easiest" path is going to be to find the surrounding text & extract based on that.

If you're willing to step your dedication to this up, you can use something like http://simplehtmldom.sourceforge.net/ & go from there.

edit: actually you can use this (it is built into php5) - http://php.net/manual/en/book.dom.php more specifically, this - http://www.php.net/manual/en/domdocument.loadhtml.php

Auston
why was I downvoted?
Auston