Hello
I am pasting my code.this code is used for data collection purpose.But i m getting an error in this.Can anybody help me?
<?php
ini_set('max_execution_time','510000');
ini_set('memory_limit','2056M');
require_once 'Classes/PHPExcel.php';
require_once 'Classes/PHPExcel/IOFactory.php';
//$zipcode=35212;
//$sleep_time=1;
//Generating sleep time random-wise
$sleep_time = rand(1,15);
$result_array=array();
$number=2;
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load("C:\Documents and Settings\Tushar.Chavan.DC\Desktop\sunlight\US_ZIP_CODES.xlsx");
$objWorksheet = $objPHPExcel->getActiveSheet();
$objPHPExcel = new PHPExcel();
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(8);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(25);
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('C1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('D1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('E1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('F1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('G1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('H1')->getFont()->setBold(true);
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 'Zipcode')
->setCellValue('B1', 'Page Number')
->setCellValue('C1', 'Retailer Name')
->setCellValue('D1', 'Address1')
->setCellValue('E1', 'Address2')
->setCellValue('F1', 'Phone')
->setCellValue('G1', 'Email Address')
->setCellValue('H1', 'Web');
$objPHPExcel->getActiveSheet()->setTitle('Sunlight_Data');
$ourFileName = "Sunlight_LogFile.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
$Data_write="Log File\r\n";
fwrite($ourFileHandle, $Data_write);
/*------------------------------------------
| BWGS
| it accept this parameter
| Zipcode - 94965
| Radius - 200
| AC-1
| Page_number-1 by default
|------------------------------------------- */
/*-----------------------------------------------------------------------
| Running only for 1st 100 records
| 06-Oct-2009
|-----------------------------------------------------------------------*/
//$highestRow = $objWorksheet->getHighestRow();
/*-----------------------------------
| ITS Area - Start
|
|---------------------------------*/
$highestRow = 41250; //ITS parameter - 1
for($row=41126 ;$row<=$highestRow;$row++) //ITS parameter - 2
{
$zipcode[$row]=$objWorksheet->getCellByColumnAndRow(0, $row)->getValue();
echo $zipcode[$row]."<br>";
}
$row=41126; //ITS parameter - 3
/*-----------------------------------
| ITS Area - End
|
|---------------------------------*/
$count_zipcode=count($zipcode);
//$count_zipcode=1;
//$zipcode[$row]='75048';
for($row_counter=0;$row_counter<$count_zipcode;$row_counter++)
{
echo $row_counter." ".$count_zipcode."<br>";
try{
/*--------------------------------------------------------------
|
| here 1 zipcode may have multiple pages for retailers
|
|--------------------------------------------------------------*/
$num_of_pages=1;
$page=1;
$counter=0;
do
{
//$url="https://www.bwgs.com/zipsearch.aspx?zip=00210&radius=200&AC=1&pg=".$page;
//$url="https://www.bwgs.com/zipsearch.aspx?zip=".$zipcode[$row]."&radius=200&AC=1&pg=".$page;
$url[$row_counter]="URL";
//$url="http://sunlight.portline.com/dealer-search.cfm?sid=28CD2645059FD4727DFCE0644D17F391&zip=00544&miles=250&city=&state=&site=&pg=2";
//$url="http://sunlight.portline.com/dealer-search.cfm?sid=28CD2645059FD4727DFCE0644D17F391&zip=42166&miles=250&city=&state=&site=&pg=2";
echo $url[$row_counter]."<br>";
flush();
ob_flush();
$ch = curl_init($url[$row_counter]);
if (!$ch) {
die( "Cannot allocate a new PHP-CURL handle" );
}
//curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
//curl_setopt($ch, CURLOPT_NOBODY, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$data[$row_counter]=curl_exec($ch);
if(!$data[$row_counter]){ throw new Exception("Data is not present \r\n"); }
//
curl_close($ch);
$first_occure=strpos($data[$row_counter],'Start Over');
$start1=$first_occure+strlen('Start Over')+1;
$end1=strrpos($data[$row_counter],'Start Over');
$length=$end1-$first_occure;
$str1=substr($data[$row_counter],$start1,$length);
$content=htmlentities($str1);
$regex_pattern = "/<a href=\"(.*)\">More Detail<\/a>/";
//echo "<pre>";
$patteren=preg_match_all($regex_pattern,$str1,$matches);
//print_r($matches[1]);
$string="class";
if($page==1)
{
$pageno_first_occure=strpos($data[$row_counter],'Displaying');
$pageno_start1=$pageno_first_occure+strlen('Displaying')+1;
$pageno_end1=strrpos($data[$row_counter],'matches');
$pageno_length=$pageno_end1-$pageno_first_occure;
$pageno_string=substr($data[$row_counter],$pageno_start1,$pageno_length);
//echo $pageno_string."---- tushar<br>";
//echo "<pre>";
$total_no_pages=explode(" ",$pageno_string);
$total_number_of_pages=ceil($total_no_pages[0]/15);
if($total_number_of_pages==0)
{
$Data="Error Zipcode : $zipcode[$row] Page : $page Excel Row number: $row \r\n";
fwrite($ourFileHandle, $Data);
break;
}
}
/*------------------------------------------------------------------
| Code for crawling the each dealers address for each zipcode
|
|------------------------------------------------------------------*/
$rank=0;
$output_array=array();
foreach($matches[1] as $key => $value)
{
$total_length=strlen($value);
$break_string_count=strpos($value,"&jar=1")."<br>";
$substitute=$total_length-$break_string_count;
//echo $str1."<br>";
$search_url=substr($value,0,$break_string_count)."<br>";
$new_url="http://sunlight.portline.com/".$search_url."&jar=1";
echo $new_url."<br>";
flush();
ob_flush();
$ch1 = curl_init($new_url);
if (!$ch1) {
die( "Cannot allocate a new PHP-CURL handle" );
}
//curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch1, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch1, CURLOPT_COOKIESESSION, 1);
//curl_setopt($ch, CURLOPT_NOBODY, TRUE);
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, FALSE);
$inner_data=curl_exec($ch1);
if(!$inner_data){ throw new Exception("Data is not present \r\n"); }
//
curl_close($ch1);
//$page=$total_number_of_pages-$page;
//echo $page." --- ".$total_number_of_pages."<br>";
$start=strpos($inner_data,'DEALER INFORMATION')+strlen('DEALER INFORMATION')+1;
$str=substr($inner_data,$start);
$a=$str;
$final=eregi_replace("(\<(/?[^\>]+)\>)","{}",$a);
$result=explode("{}",$final);
$lmn=0;
//echo "<pre>";
//print_r($result);
//exit;
for($k=0;$k<count($result);$k++)
{
$result[$k]=trim($result[$k]);
if((($result[$k]!='')&&(!empty($result[$k])))&&($result[$k]))
{
if($result[$k]=='Go Back')
break;
$output_array[$rank][$lmn]=$result[$k];
$lmn++;
}
}
$rank++;
}// end of foreach for each more detail link
//echo "<pre>";
//print_r($output_array);
//echo "<br>";
$count=count($output_array);
//echo "<pre>";
//print_r($output_array);
//exit;
for($j=0;$j<$count;$j++)
{
$check_count=count($output_array[$j]);
if($check_count==8)
{
/*----------------------------------
| 8 - Start
|----------------------------------*/
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $number, $zipcode[$row]);
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $number, $page);
//Dealer name
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, $number, strip_tags($output_array[$j][1]));
//Dealer Address - 1
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, $number, str_replace(' ',' ',$output_array[$j][2]));
$address=$output_array[$j][3].", ".$output_array[$j][4];
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $number, str_replace(' ',' ',$address));
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $number, str_replace(' ',' ',$output_array[$j][5]));
$objPHPExcel->getActiveSheet()->getStyle('E'.$number)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $number, str_replace(' ',' ',$output_array[$j][6]));
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $number, str_replace(' ',' ',$output_array[$j][7]));
/*----------------------------------
| 8 - End
|----------------------------------*/
}
else
if($check_count==7)
{
/*----------------------------------
| 7 - Start
|----------------------------------*/
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $number, $zipcode[$row]);
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $number, $page);
//Dealer name
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, $number, strip_tags($output_array[$j][1]));
//Dealer Address - 1
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, $number, str_replace(' ',' ',$output_array[$j][2]));
$address3_exist_flag=false;
$objPHPExcel->getActiveSheet()->getStyle('E'.$number)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
if(preg_match("/^((\w+\.){1,})\w{2,}$/i",$output_array[$j][5]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $number, str_replace(' ',' ',$output_array[$j][5])); }
else
if(preg_match('/^((http:\/\/|https:\/\/|ftp:\/\/){0,})([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $output_array[$j][5]))
//if (preg_match("/^(http(s?):\/\/|ftp:\/\/{1})((\w+\.){1,})\w{2,}$/i", $output_array[$j][5]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $number, str_replace(' ',' ',$output_array[$j][5]));
}
else if(preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])*(\.([a-z0-9])([-a-z0-9_-])([a-z0-9])+)*$/i', $output_array[$j][5]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $number, str_replace(' ',' ',$output_array[$j][5]));
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $number, str_replace(' ',' ',$output_array[$j][6]));
}
else
if (preg_match('/\(?\d{3}\)?[-\s.]?\d{3}[-\s.]\d{4}/x', $output_array[$j][5]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $number, str_replace(' ',' ',$output_array[$j][5]));
if(preg_match("/^((\w+\.){1,})\w{2,}$/i",$output_array[$j][6]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $number, str_replace(' ',' ',$output_array[$j][6])); }
else if(preg_match('/^((http:\/\/|https:\/\/|ftp:\/\/){0,})([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $output_array[$j][6]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $number, str_replace(' ',' ',$output_array[$j][6]));
}
else if(preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])*(\.([a-z0-9])([-a-z0-9_-])([a-z0-9])+)*$/i', $output_array[$j][6]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $number, str_replace(' ',' ',$output_array[$j][6]));
}
else
{
}
}
else
{
$address3_exist_flag=true;
}
if($address3_exist_flag==false)
{
if (preg_match('/\(?\d{3}\)?[-\s.]?\d{3}[-\s.]\d{4}/x', $output_array[$j][4]))
{
$address=$output_array[$j][3];
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $number, str_replace(' ',' ',$address));
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $number, str_replace(' ',' ',$output_array[$j][4]));
}
else
{
$address=$output_array[$j][3]." ".$output_array[$j][4];
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $number, str_replace(' ',' ',$address));
}
}
else//this will never execute
{
$address=$output_array[$j][3]." ".$output_array[$j][4]." ".$output_array[$j][5];
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $number, str_replace(' ',' ',$address));
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $number, str_replace(' ',' ',$output_array[$j][6]));
}
/*----------------------------------
| 7 - End
|----------------------------------*/
}
else
if($check_count==6)
{
/*----------------------------------
| 6 - Start
|----------------------------------*/
$address3_exist_flag=false;
$Phone_exist_flag=false;
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $number, $zipcode[$row]);
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $number, $page);
//Dealer name
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, $number, strip_tags($output_array[$j][1]));
//Dealer Address - 1
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, $number, str_replace(' ',' ',$output_array[$j][2]));
$objPHPExcel->getActiveSheet()->getStyle('E'.$number)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
if(preg_match("/^((\w+\.){1,})\w{2,}$/i",$output_array[$j][5]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $number, str_replace(' ',' ',$output_array[$j][5]));
}elseif(preg_match('/^((http:\/\/|https:\/\/|ftp:\/\/){0,})([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $output_array[$j][5]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $number, str_replace(' ',' ',$output_array[$j][5]));
}
else if(preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])*(\.([a-z0-9])([-a-z0-9_-])([a-z0-9])+)*$/i', $output_array[$j][5]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $number, str_replace(' ',' ',$output_array[$j][5]));
}
else
if (preg_match('/\(?\d{3}\)?[-\s.]?\d{3}[-\s.]\d{4}/x', $output_array[$j][5]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $number, str_replace(' ',' ',$output_array[$j][5]));
$Phone_exist_flag=true;
}
else
{
$address3_exist_flag=true;
}
if($Phone_exist_flag==false)//if phone exist at 5 then all other are addresses
{
if($address3_exist_flag==false)
{
$data_num=$output_array[$j][3];
$data_num1=str_replace('(','',$data_num);
$data_num2=str_replace(')','',$data_num1);
$data_num3=str_replace('-',' ',$data_num2);
$data_num4=str_replace(' ','',$data_num3);
if(is_numeric($data_num4))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $number, str_replace(' ',' ',$output_array[$j][3]));
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $number, str_replace(' ',' ',$output_array[$j][4]));
}
else
{
$address=$output_array[$j][3];
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $number, str_replace(' ',' ',$address));
$data_num5=$output_array[$j][4];
$data_num6=str_replace('(','',$data_num5);
$data_num7=str_replace(')','',$data_num6);
$data_num8=str_replace('-',' ',$data_num7);
$data_num9=str_replace(' ','',$data_num8);
if(is_numeric($data_num9))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $number, str_replace(' ',' ',$output_array[$j][4]));
}
else
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $number, str_replace(' ',' ',$output_array[$j][4]));
}
}
}
else
{
//since values at 5th posotion is also array
$address=$output_array[$j][3]." ".$output_array[$j][4]." ".$output_array[$j][5];
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $number, str_replace(' ',' ',$address));
//$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $number, str_replace(' ',' ',$output_array[$j][5]));
}
}
else
{
$address1=$output_array[$j][3]." ".$output_array[$j][4];
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $number, str_replace(' ',' ',$address1));
}
/*----------------------------------
| 6 - End
|----------------------------------*/
}
else
if($check_count==5)
{
/*----------------------------------
| 5 - Start
|----------------------------------*/
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $number, $zipcode[$row]);
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $number, $page);
//Dealer name
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, $number, strip_tags($output_array[$j][1]));
//Dealer Address - 1
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, $number, str_replace(' ',' ',$output_array[$j][2]));
$address3_exist_flag=false;
$objPHPExcel->getActiveSheet()->getStyle('E'.$number)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
if(preg_match("/^((\w+\.){1,})\w{2,}$/i",$output_array[$j][4]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $number, str_replace(' ',' ',$output_array[$j][4]));
}elseif(preg_match('/^((http:\/\/|https:\/\/|ftp:\/\/){0,})([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $output_array[$j][4]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $number, str_replace(' ',' ',$output_array[$j][4]));
}
else if(preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])*(\.([a-z0-9])([-a-z0-9_-])([a-z0-9])+)*$/i', $output_array[$j][4]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $number, str_replace(' ',' ',$output_array[$j][4]));
}
else
if (preg_match('/\(?\d{3}\)?[-\s.]?\d{3}[-\s.]\d{4}/x', $output_array[$j][4]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $number, str_replace(' ',' ',$output_array[$j][4]));
}
else
{
$address3_exist_flag=true;
}
if($address3_exist_flag==false)
{
//for telephone number
if (preg_match('/\(?\d{3}\)?[-\s.]?\d{3}[-\s.]\d{4}/x', $output_array[$j][3]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $number, str_replace(' ',' ',$output_array[$j][3]));
}
else//for address
{
$address=$output_array[$j][3];
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $number, str_replace(' ',' ',$address));
}
}
else
{
$address=$output_array[$j][3]." ".$output_array[$j][4];
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $number, str_replace(' ',' ',$address));
}
/*
$address=$output_array[$j][3];
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $number, str_replace(' ',' ',$address));
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $number, str_replace(' ',' ',$output_array[$j][4]));
*/
/*----------------------------------
| 5 - End
|----------------------------------*/
}
else
if($check_count==4)
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $number, $zipcode[$row]);
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $number, $page);
//Dealer name
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, $number, strip_tags($output_array[$j][1]));
//Dealer Address - 1
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, $number, str_replace(' ',' ',$output_array[$j][2]));
if(preg_match("/^((\w+\.){1,})\w{2,}$/i",$output_array[$j][3]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $number, str_replace(' ',' ',$output_array[$j][3]));
}elseif(preg_match('/^((http:\/\/|https:\/\/|ftp:\/\/){0,})([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $output_array[$j][3]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $number, str_replace(' ',' ',$output_array[$j][3]));
}
else if(preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])*(\.([a-z0-9])([-a-z0-9_-])([a-z0-9])+)*$/i', $output_array[$j][3]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $number, str_replace(' ',' ',$output_array[$j][3]));
}
else
if (preg_match('/\(?\d{3}\)?[-\s.]?\d{3}[-\s.]\d{4}/x', $output_array[$j][3]))
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $number, str_replace(' ',' ',$output_array[$j][3]));
}
else
{
$address=$output_array[$j][3];
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $number, str_replace(' ',' ',$address));
}
}
else
{
/*----------------------------------
| Other - Start
|----------------------------------*/
/*----------------------------------
| Other - End
|----------------------------------*/
}
$number++;
}
//$num_of_pages=$num_of_pages-$page;
$Data="Completed successfully Zipcode : $zipcode[$row] Row: $row Page: $page\r\n";
fwrite($ourFileHandle, $Data);
$page++;
$counter++;
}while($total_number_of_pages!=$counter);
sleep($sleep_time);
}
catch(Exception $e)
{
$Data="Error Zipcode : $zipcode[$row] Row: $row \r\n";
echo $Data." ".$e."<br>";
flush();
ob_flush();
fwrite($ourFileHandle, $Data);
}
$row++;
}
//exit;
fclose($ourFileHandle);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objPHPExcel->setActiveSheetIndex(0);
$objWriter->save('Sunlight_Data_logic.xlsx');
echo "<br>Done Excel report generated.<br>";
//echo "<br>Done - Send mail to tapan sir : open ITS_INSTRUCTIONS.txt file from dekstop it contains all the details. Thanks<br>";
flush();
ob_flush();
?>