I want to get text from URL and store that to the array. And I have existing array. So, how can I compare that two array? I have tried this. But this coding is giving not match always.
What I have tried:
<?php
$url = 'http://www.test.oddly.co/robots.txt';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, 1);
$result = curl_exec($curl);
curl_close($curl);
echo $result.'
';
$arr = array("kadirgamar","arrow","orion","woolimlanka","nippon","luna-tower","thotalagala","altair","arrowlibrary",
"ashraf","ashrafnew","invoke","lavana","leia","lorelle","lioc","liocdev","lorellenew","openmanthri","opentapes ","
rates","rsq","signature","site","visualretale","srhr","smitratest","smitra","lioccontent","lioccopy","liocold","
global","echelon","arrowlive"
);
$array = explode('Disallow: / ',$result);
unset($array[0]);
$array = array_values($array);
function trim_array_element(&$item1)
{
$item1 = preg_replace('/\//', '', $item1);
}
array_walk($array,'trim_array_element');
print_r($array).'
';
print_r($arr);
if($array === array_intersect($array, $arr) && $arr === array_intersect($arr, $array))
{
echo "Both arrays are equal.";
}
else
{
echo "Both arrays are different.";
}
?>