Jump to content

[SOLVED] Number of char in string


hassank1

Recommended Posts

#1) I LOVE http://letmegooglethatforyou.com/ ....it's fantastic

 

the OP asked about occurrences of A character though. to my knowledge, there is no built in function...there are lot's of other ways to do it though. one easy way that comes to mind is to split on it:

 

<?php
  $str = "Hello World!";
  $find = 'o';
  $count = count(explode($find,$str)) - 1;
  print $count;
?>

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.