I have two questions: 1. How to break a string into an array given a start string and end string make array element out of everything inbetween. 2. Compare my new array with another array and if any elements match let the user know which values match.
I need to break the contents of a string into an array I need the values of the mac address
[MAC]
mac=12EG23OCSOPC
mac=111111111111
mac=222222222222
mac=333333333333
I need the values of everything after "mac=" and before the \n
and then I need to compare these values with another array, if there are items that are the same i need to let the user know which ones match This is what I have so far.
function count_compare_macs($macs_to_compare, $new_array)
{
$macs_to_compare_count = count($macs_to_compare);
$new_array_count = count($new_array);
if(($macs_to_compare_count + $new_array_count) >= 5)
{
return false;
$error_message="You already have 5 MAC address in your system";
}else{
//here is where i need to compare the two arrays and if any are the same say false and set the error message.
$compare_arrays = array_Diff($macs_to_compare,$new_array)
if (!$compare_arrays){
return true;
}else{
//here is where i need to compare the two arrays and if any are the same say false and set the error message.
$error_message= "The following mac is already used" . $match
return false;
}
}
}