This is my code
$datas= array("AAA","BBB","CCC","AAAAAA","BBBBBB","CCCCCCCCC");
$code = "AAAAAA-BBBBBB-CCCCCCCCC";
for($i=0;$i<count($datas); $i++){
$pos = strpos($code ,$datas[$i]);
if($pos!== false){
$this->valid_array[$i] = array("DATA"=> $datas[$i],"SPLITTER"=>substr($code ,strlen($datas[$i]),1));
}
}
What I need is,
I need to find string inside $code from $datas array. I am using strpos function to find.
The problem is,
The strpos is returning 0 for first index of $datas. $datas[0] contain only 3 A.
But I need only the matched values. How can I check this as strict ?
Expected output is, eg: $code = "AAAAAA-BBBBBB-CCCCCCCCC";
I am looping through the $datas array for checking the $datas elements included in the $code. if it is included I am constructing new "$valid_array
" array. so if the code matches elements in the $datas array. the code is correct and I need to return the code. Thanks.