I'm looking for a regex expression to use with php :
I have 4 strings like this in array :
$strA = 'John P. Beck'; // name and surname
$strB = '12012 BlaBla Xx'; // street
$strC = 'Houston TX 12345-6789'; // city + zip code
$strD = '(123) 456-7890'; // telephone number
By now i'm using a regex in a for loop but it always returns me both the first and the second string, and sometimes the first and the third string....
for($i = 0; $i < count($array); $i++)
{
if(preg_match("/[A-Z]/", $array[$i]))
{
echo $array[$i] . '<br>';
}
else echo 'no match<br>';
}
I need a regex with this conditions : - at least 1 Uppercase in string AND absolutely NO digits... to return only $strA.....
Thank you very much
EDIT
sorry maybe I explained myself bad and without adding details... This is the structure of the array (example):
[0] => <p>
[1] => 41
[2] => <br />
[3] => John P. Beck
[4] => <br />
[5] => 12012 BlaBla Xx
[6] => <br />
[7] => Houston TX 12345-6789
[8] => <br />
[9] => (123) 456-7890
[10] => <br />
[11] => 42
[12] => <br />
[13] => Linda F. Green
[14] => <br />
[15] => 1888 BlaBla Xx
[16] => <br />
[17] => Saint Louis, MO 12345-6789
[18] => <br />
[19] => (123) 456-7890
[20] => <br />
...
...
...
I need to store only the 4th string and the 14th string.. and so on ...
@nickb : with $array[0] it returns always a p tag.. i'm in a for loop...... :)
echo $array[0];. Problem solved.