Inspection of the output screenshot of the code (see previous section) shows a complicated type of array commonly known in PHP as a "multi-dimensional array." By analyzing this type of array we can grab our desired data from the Yahoo inbound links explorer API.
To process multi-dimensional arrays, let's first do a little thought experiment. Suppose we wish to simulate the results in the previous screenshot using a PHP code; this is essential to our understanding of these arrays, which we can analyze further to grab the required data.
Again, you might find that the outermost array starts with [ResultSet]; this is the root array. Then the root array consists of four further arrays, namely:
The most important data can be found in the [Result] array. For example, the array  is the first back link data with the following innermost arrays:
To simulate an equivalent PHP code that will give the array structure in the earlier screenshot, start from the innermost array and work your way to the outermost array:
//This is the innermost array that contains the title tag, Url...etc
$innerarray0= array('Title' => 'This is a title0', 'Url' => 'This is the URL0', 'ClickUrl' => 'This is the ClickUrl0');
$innerarray1= array('Title' => 'This is a title1', 'Url' => 'This is the URL1', 'ClickUrl' => 'This is the ClickUrl1');
$innerarray2= array('Title' => 'This is a title2', 'Url' => 'This is the URL2', 'ClickUrl' => 'This is the ClickUrl2');
//This is the counter array starting from 0 to 2, based on the number of results you have requested from the Yahoo explorer inbound links API
$arraycount= array(0 =>$innerarray0,1=>$innerarray1,2=>$innerarray2);
//The second outer array that contains the total number of backlinks, results, starting position
$outerarray = array('totalResultsAvailable' => 569,'firstResultPosition' => 1, 'totalResultsReturned' => 3,'Result'=> $arraycount);
//This is the outermost array [ResultSet]
//PHP code to display this simulated PHP code that replicates the Yahoo explorer inbound links API response PHP array
echo '<br />';
Below is the screenshot of the PHP code output:
Now the above simulated PHP code output screenshot has exactly the same array structure as the original unserialized response array of inbound links explorer API (see previous screenshot).
blog comments powered by Disqus