I wish it show as
unfulfilled:bb,cc
extra provided:dd
as my conditions and provided strings will be unconstant, anyone can suggest me some ways to do it?
Finding substring in string
<?php
$condition="aa,bb,cc";
$provided="aa,dd";
$arr1=explode(",",$condition);
$arr2=explode(",",$provided);
$b=0;
$c=0;
//check sizes of arrays
if(count($arr1)>count($arr2))
{
$size=count($arr1);
$a=count($arr2);
}
else
{
$size=count($arr2);
$a=count($arr1);
}
//compare both arrays
for($i=0;$i<$size;$i=$i+1)
{
for($j=0;$j<$a;$j=$j+1)
{
if($arr1[$i]==$arr2[$j])
{
$num=$num+1; //check number of matched
$arr3[$b]=$arr1[$i]; //assign matched to new array
$b=$b+1;
}
}
}
echo $num.'matched: ';
while($c<$b)
{
echo $arr3[$c]." ";
$c=$c+1;
}
echo "<br>";
?>
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.