stijn0713 Posted June 24, 2012 Share Posted June 24, 2012 i get this error: preg_match(): Delimiter must not be alphanumeric or backslash, when i run the following code: function zetjuistvolgorde($SandTs){ $arr1 = array(); $arr2 = array(); for ($i = 0; $i <= count($SandTs); $i++){ if(preg_match('t.', "{$SandTs[$i]}")){ $arr1 = $SandTs[$i]; } else { $arr2 = $SandTs[$i]; } } $arr = array_merge($arr1, $arr2); return $arr; } The purpose is that an array which countains variables like e.g. t1 t2 s1 s2 t3 s3 will be sorted so that all the t's comes first. Apparently it doesn't work but i have no clue what the error means. Can somebody help me? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/264692-preg_match/ Share on other sites More sharing options...
premiso Posted June 24, 2012 Share Posted June 24, 2012 Check out what a delimiter is ( http://php.net/preg_match ) there should be a link on the manual. To fix your issue: if(preg_match('#t.#', "{$SandTs[$i]}")){ In this case we are using # as the delimiter. Quote Link to comment https://forums.phpfreaks.com/topic/264692-preg_match/#findComment-1356613 Share on other sites More sharing options...
stijn0713 Posted June 24, 2012 Author Share Posted June 24, 2012 Oh, thanks. I checked it but the manuel doesn't reference to this in the section on preg_match. That's a bit confusing Quote Link to comment https://forums.phpfreaks.com/topic/264692-preg_match/#findComment-1356626 Share on other sites More sharing options...
premiso Posted June 24, 2012 Share Posted June 24, 2012 You are right, it does mention it under the PCRE Patterns in the See Also, maybe I will bug Salathe to see if he feels like changing that up. Quote Link to comment https://forums.phpfreaks.com/topic/264692-preg_match/#findComment-1356629 Share on other sites More sharing options...
salathe Posted June 24, 2012 Share Posted June 24, 2012 The preg_match() page already links through to the "PCRE Patterns" chapter, from there it should not have proved tricky (though clearly did) to find what you needed. Two of the four further links on that ("PCRE Patterns") page mention delimiters, and take you right to the detailed information about them. I can only advise that people read through the PCRE Patterns chapter before trying to use the associated functions. A link could be added from the preg_match() page directly to the "Delimiters" page, but where do we draw the line? Should the function page also link to the Performance, Repetition, Character classes, ... pages? Quote Link to comment https://forums.phpfreaks.com/topic/264692-preg_match/#findComment-1356631 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.