Category Archives: PHP

Function to combine arrays – PHP

<?php
 $testArray1 = array("place" => "kochi", 11, 12);
 $testArray2 = array("p", "s", "place" => "Tvm", "Width" => "10", 84);
 $testArray3 = array_merge($testArray1, $testArray2);
 print_r($testArray3);
 //Array ( [place] => Tvm [0] => 11 [1] => 12 [2] => p [3] 
 //=> s [Width] => 10 [4] => 84 )
?>

Script to read RSS feed – PHP

<?php
 $connect = curl_init("http://www.unixsite.com/feed/rss/");
 curl_setopt($connect, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($connect, CURLOPT_HEADER, 0) ;
 $result = curl_exec($connect);
 curl_close($connect);
 $data = new SimpleXmlElement($result, LIBXML_NOCDATA);
 for($i=0;$i<10;++$i) {
  if(empty($data->channel->item[$i]->title)) break;
  echo  $data->channel->item[$i]->title; 
  echo  $data->channel->item[$i]->description; 
 }
?>