redarrow Posted October 11, 2008 Share Posted October 11, 2008 advance thank you hi there marsters off the regular exsprisions, i have the below regex going on to understand preg_match, im learning the preg functions for regular exspresions.. as you can see i have the correct result where the preg_match gives a 1 meaning a match..... i used a 3rd varable to see what it has matched it shows the array as demo below...... q1. i dont understand the array at all, why dosent it just show 1 result and shows 2 why? q2. why hasent the array got my other 3 maches in the array.... q3.([0-9\.]{5}[0-9\.]{5}[0-9\.]{5}[0-9]{4}) << what condition to show all off the maches on the array should i use looks like it only looking for 1 match.... there three maches.... <?php $name="my name is 1234.1234.1234.1234 redarrow 4536.7867.5465.7898 7869.2343.8712.3461"; $pattern="/([0-9\.]{5}[0-9\.]{5}[0-9\.]{5}[0-9]{4})/i"; preg_match($pattern,$name,$result[]); print_r($result); ?> array result. Array ( [0] => Array ( [0] => 1234.1234.1234.1234 [1] => 1234.1234.1234.1234 ) ) Link to comment https://forums.phpfreaks.com/topic/128025-solved-preg_match-help-please/ Share on other sites More sharing options...
redarrow Posted October 11, 2008 Author Share Posted October 11, 2008 SOLVED must be my zend php writter plying up sorry................ SORRY ARRAY [0][0] MATCHED WITH [0][1] with this pattern $pattern="/([0-9\.]{5}[0-9\.]{5}[0-9\.]{5}[0-9]{4})/i"; <?php $name="my name is 1234.1234.1234.1234 redarrow 4536.7867.5465.7898 7869.2343.8712.3461"; $pattern="/([0-9\.]{5}[0-9\.]{5}[0-9\.]{5}[0-9]{4})/i"; preg_match_all($pattern,$name,$result[]); print_r($result); ?> Array ( [0] => Array ( [0] => Array ( [0] => 1234.1234.1234.1234 [1] => 4536.7867.5465.7898 [2] => 7869.2343.8712.3461 ) [1] => Array ( [0] => 1234.1234.1234.1234 [1] => 4536.7867.5465.7898 [2] => 7869.2343.8712.3461 ) ) ) Link to comment https://forums.phpfreaks.com/topic/128025-solved-preg_match-help-please/#findComment-662955 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.