Reputation: 417
the string present in the array are ATA Report of 7th Apr 2014, ATA Report of 17th Apr 2014, ATA Report of 27th Apr 2014
I have the sub string 7th Apr 2014
How can I find ATA Report of 7th Apr 2014
position
I hav used like this but not worked for me
$date = "7th Apr 2014"
if (strpos("ATA Report of 7th Apr 2014", $date) !== false){
//my code.........
}
Upvotes: 1
Views: 47
Reputation: 68546
You need to loop them over..
<?php
$arr=array("ATA Report of 7th Apr 2014", "ATA Report of 17th Apr 2014", "ATA Report of 27th Apr 2014");
foreach($arr as $k=>$v)
{
if(strpos($v,"7th Apr 2014") !== false)
{
echo "The position is $k";
break;
}
}
Also, the strpos()
you are using it in a wrong way... the haystack should come first , followed by the needle.
Upvotes: 1