Jump to content

can u count how many a's in a string...


brown2005

Recommended Posts

Another way that comes to mind is preg_match_all(), but it may be overkill for what you're after:
[code]
<?php
$String = "Yes I am able to go to the pub tommorrow";
preg_match_all('|a|i', $String, $matches, PREG_SET_ORDER);
echo count($matches) . " a's found!";
?>
[/code]

Try it and see... I haven't actually tested it yet :(

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.