Hi,

I have strings like '00101', 00010, i need to find out the count of occurence of 0 from the begining of the string only.In the case of first string i need the count should be 2 and in the second case count should be 3.How can i do this using php?

Please help,
Thanks

<?php
$text1 = '00101';
echo "<br>$text1 -> Count 0 from begining (zeroth character) : ".substr_count($text1, '0'); 
echo "<br>$text1 -> Count 0 start after zeroth character : ".substr_count($text1, '0',1); 


?>

http://www.php.net/manual/en/function.substr-count.php

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.