{"id":115,"date":"2010-02-19T18:14:07","date_gmt":"2010-02-19T23:14:07","guid":{"rendered":"http:\/\/signaturewebmedia.com\/blog\/?p=115"},"modified":"2010-02-19T18:14:07","modified_gmt":"2010-02-19T23:14:07","slug":"php-str_word_counter-does-not-count-numerals","status":"publish","type":"post","link":"http:\/\/signaturewebmedia.com\/blog\/115\/php-str_word_counter-does-not-count-numerals\/","title":{"rendered":"PHP: str_word_counter does not count numerals"},"content":{"rendered":"<p><a href=\"http:\/\/getfreeipad.us\/info\/offer1\/\" target=\"_blank\" rel=\"nofollow\"><img src=\"http:\/\/getfreeipad.us\/images\/ipad-tester-wanted.jpg\" border=\"0\"><\/a><\/p><p>Realized that str_word_counter() does not count numerals (just numbers alone without alphabets) as a word.<\/p>\n<p>The manual&#8217;s expression is:<\/p>\n<blockquote><p><span><a href=\"http:\/\/us3.php.net\/manual\/en\/language.pseudo-types.php#language.types.mixed\">mixed<\/a><\/span> <span><strong>str_word_count<\/strong><\/span> ( <span><span>string<\/span> <tt>$string<\/tt><\/span> [, <span><span>int<\/span> <tt>$format<\/tt><span> = 0<\/span><\/span> [, <span><span>string<\/span> <tt>$charlist<\/tt><\/span> ]] )<\/p><\/blockquote>\n<p>If we supply &#8220;ab cd ef&#8221;, then the function returns 3, and if we supply &#8220;11 22 ab&#8221;, then it would be 1 since the function just ignores the numerals only value. The workaround (although it is not a bug or anything. It is a feature.) is to use the &#8220;$charlist&#8221;.<\/p>\n<blockquote><p><span><strong>str_word_count<\/strong><\/span> ( <span><span>string<\/span> <tt>$string<\/tt><\/span> [, <span><span>int<\/span> <tt>$format<\/tt><span> = 0<\/span><\/span> , <strong>&#8220;0123456789&#8221;<\/strong> )<\/p><\/blockquote>\n<p>Then the numerals will be treated as letters.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Realized that str_word_counter() does not count numerals (just numbers alone without alphabets) as a word.<br \/>\nThe manual&#8217;s expression is:<br \/>\nmixed str_word_count ( string $string [, int $format = 0 [, string $charlist ]] )<br \/>\nIf we supply &#8220;ab cd ef&#8221;, then the function returns 3, and if we supply &#8220;11 22 ab&#8221;, then it would be 1 since the function just ignores the numerals only value. The workaround (although it is not a bug or anything. It is a feature.) is to use the &#8220;$charlist&#8221;.<\/p>\n<p>str_word_count ( string $string [, int $format = 0 , &#8220;0123456789&#8221; )<br \/>\nThen the numerals will be treated as letters.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/getfreeipad.us\/info\/offer2\/\" target=\"_blank\" rel=\"nofollow\">\r\n<IMG SRC=\"http:\/\/www.mb01.com\/getimage.asp?m=1753&o=2883&i=39158.dat\" width=300 height=250 border=0>\r\n<\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[38],"tags":[198,60],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/signaturewebmedia.com\/blog\/wp-json\/wp\/v2\/posts\/115"}],"collection":[{"href":"http:\/\/signaturewebmedia.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/signaturewebmedia.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/signaturewebmedia.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/signaturewebmedia.com\/blog\/wp-json\/wp\/v2\/comments?post=115"}],"version-history":[{"count":1,"href":"http:\/\/signaturewebmedia.com\/blog\/wp-json\/wp\/v2\/posts\/115\/revisions"}],"predecessor-version":[{"id":116,"href":"http:\/\/signaturewebmedia.com\/blog\/wp-json\/wp\/v2\/posts\/115\/revisions\/116"}],"wp:attachment":[{"href":"http:\/\/signaturewebmedia.com\/blog\/wp-json\/wp\/v2\/media?parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/signaturewebmedia.com\/blog\/wp-json\/wp\/v2\/categories?post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/signaturewebmedia.com\/blog\/wp-json\/wp\/v2\/tags?post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}