DevelopPHP
home Forum gear home

Libraries book

HTML Library CSS Library JavaScript Library PHP Library

Videosbook

PHP and MySQL JavaScript HTML and CSS Vector and 3D Flash Actionscript Android Dev Miscellaneous

Resourcesbook

Website Hosting
str_word_count ( ) - Find the number of words in a string   Share / Like
The str_word_count() function will let you know how many words are in a string you pass through it. You can use one or two parameters in this function. We explain the parameter use in the code below.

Learn HTML
<?php
$myString 
"Programmers are dorks!";
// Return the number of words by using "0" or supply no second parameter
$count str_word_count($myString0);
echo 
$count."<br />";
// Return a normal array with all of the words in it by using "1"
$countArray str_word_count($myString1);
echo 
serialize($countArray)."<br />";
// Return an associative array by using "2" as the second parameter
$countArray str_word_count($myString2);
echo 
serialize($countArray)."<br />";
?>

Develop PHP browser display window
3
a:3:{i:0;s:11:"Programmers";i:1;s:3:"are";i:2;s:5:"dorks";}
a:3:{i:0;s:11:"Programmers";i:12;s:3:"are";i:16;s:5:"dorks";}


Home   •   Terms of Use   •   Developer Forums   •   T-Shirts   •   RSS   •   Classroom Chalkboard   •   Donate   •   Top ↑
Popular In PHP / MySQL E-Commerce Store Production
Social Network Website Building
Image Upload / Photo Processing
CMS Software Programming
Mass Email Systems
Magic XML Data
Search Programming
Popular In JavaScript JSON Programming
Ajax Programming
Animating Elements
WYSIWYG Programming
Date/Time Programming
DOM Scripting
Object Reference
Popular In HTML Canvas Element
New Form Elements
Audio Element
Video Element
Drag and Drop
Event Handling
Element Grouping
Popular In CSS Custom Font Embedding
Dynamic Fit Backgrounds
Theatre Mode
Box Overlays
CSS Level 1 Properties
CSS Level 2 Properties
CSS Level 3 Properties
©2013 DevelopPHP   |   Navigate to related domains HTML5