papaface Posted February 19, 2008 Share Posted February 19, 2008 Hello, Can someone please tell me how I would go about finding the first alphanumeric character in a string? Thank you Quote Link to comment Share on other sites More sharing options...
craygo Posted February 19, 2008 Share Posted February 19, 2008 can try putting a couple functions together <?php $string = "Here! is some text, and numbers 12345, and symbols !£$%^&"; $new_string = preg_replace("/[^a-zA-Z0-9s]/", "", $string); $first_alpha = substr($new_string,0,1); echo $first_alpha; ?> Ray Quote Link to comment Share on other sites More sharing options...
effigy Posted February 19, 2008 Share Posted February 19, 2008 In terms of ASCII: <pre> <?php $data = '#(%*@(*$!*A1B'; preg_match('/[a-z\d]/i', $data, $matches); print_r($matches); ?> </pre> Quote Link to comment Share on other sites More sharing options...
papaface Posted February 19, 2008 Author Share Posted February 19, 2008 Thanks Quote Link to comment 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.