@Test public void testSubstr_count_String_char() { logger.info("substr_count"); String string = "test test"; char character = 't'; int expResult = 4; int result = PHPMethods.substr_count(string, character); assertEquals(expResult, result); }
public static int substr_count(final String string, final String substring) { if(substring.length()==1) { return substr_count(string, substring.charAt(0)); } int count = 0; int idx = 0; while ((idx = string.indexOf(substring, idx)) != -1) { ++idx; ++count; } return count; }
PHPMethods { public static int substr_count(final String string, final String substring) { if(substring.length()==1) { return substr_count(string, substring.charAt(0)); } int count = 0; int idx = 0; while ((idx = string.indexOf(substring, idx)) != -1) { ++idx; ++count; } return count; } }
PHPMethods { public static int substr_count(final String string, final String substring) { if(substring.length()==1) { return substr_count(string, substring.charAt(0)); } int count = 0; int idx = 0; while ((idx = string.indexOf(substring, idx)) != -1) { ++idx; ++count; } return count; }  }
PHPMethods { public static int substr_count(final String string, final String substring) { if(substring.length()==1) { return substr_count(string, substring.charAt(0)); } int count = 0; int idx = 0; while ((idx = string.indexOf(substring, idx)) != -1) { ++idx; ++count; } return count; }  static String ltrim(String s); static String rtrim(String s); static int substr_count(final String string, final String substring); static int substr_count(final String string, final char character); static String preg_replace(String regex, String replacement, String subject); static String preg_replace(Pattern pattern, String replacement, String subject); static int preg_match(String regex, String subject); static int preg_match(Pattern pattern, String subject); static double round(double d, int i); static double log(double d, double base); static int mt_rand(); static int mt_rand(int min, int max); static double mt_rand(double min, double max); static Map<V,K> array_flip(Map<K,V> map); static void shuffle(T[] array); static void shuffle(T[] array, Random rnd); static Integer[] asort(T[] array); static Integer[] arsort(T[] array); static void arrangeByIndex(T[] array, Integer[] indexes); static double[] array_clone(double[] a); static double[][] array_clone(double[][] a); }
PHPMethods { public static int substr_count(final String string, final String substring) { if(substring.length()==1) { return substr_count(string, substring.charAt(0)); } int count = 0; int idx = 0; while ((idx = string.indexOf(substring, idx)) != -1) { ++idx; ++count; } return count; }  static String ltrim(String s); static String rtrim(String s); static int substr_count(final String string, final String substring); static int substr_count(final String string, final char character); static String preg_replace(String regex, String replacement, String subject); static String preg_replace(Pattern pattern, String replacement, String subject); static int preg_match(String regex, String subject); static int preg_match(Pattern pattern, String subject); static double round(double d, int i); static double log(double d, double base); static int mt_rand(); static int mt_rand(int min, int max); static double mt_rand(double min, double max); static Map<V,K> array_flip(Map<K,V> map); static void shuffle(T[] array); static void shuffle(T[] array, Random rnd); static Integer[] asort(T[] array); static Integer[] arsort(T[] array); static void arrangeByIndex(T[] array, Integer[] indexes); static double[] array_clone(double[] a); static double[][] array_clone(double[][] a);  }