<HTML ><HEAD ><TITLE >str_word_count</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="String functions" HREF="ref.strings.html"><LINK REL="PREVIOUS" TITLE="str_shuffle" HREF="function.str-shuffle.html"><LINK REL="NEXT" TITLE="strcasecmp" HREF="function.strcasecmp.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.str-shuffle.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.strcasecmp.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.str-word-count" ></A >str_word_count</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN90945" ></A ><P > (PHP 4 >= 4.3.0)</P >str_word_count -- Return information about words used in a string </DIV ><DIV CLASS="refsect1" ><A NAME="AEN90948" ></A ><H2 >Description</H2 >mixed <B CLASS="methodname" >str_word_count</B > ( string string [, int format])<BR ></BR ><P > Counts the number of words inside <TT CLASS="parameter" ><I >string</I ></TT >. If the optional <TT CLASS="parameter" ><I >format</I ></TT > is not specified, then the return value will be an integer representing the number of words found. In the event the <TT CLASS="parameter" ><I >format</I ></TT > is specified, the return value will be an array, content of which is dependent on the <TT CLASS="parameter" ><I >format</I ></TT >. The possible value for the <TT CLASS="parameter" ><I >format</I ></TT > and the resultant outputs are listed below. <P ></P ><UL ><LI ><P > 1 - returns an array containing all the words found inside the <TT CLASS="parameter" ><I >string</I ></TT >. </P ></LI ><LI ><P > 2 - returns an associative array, where the key is the numeric position of the word inside the <TT CLASS="parameter" ><I >string</I ></TT > and the value is the actual word itself. </P ></LI ></UL > </P ><P > For the purpose of this function, 'word' is defined as a locale dependent string containing alphabetic characters, which also may contain, but not start with "'" and "-" characters. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.str-shuffle.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.strcasecmp.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >str_shuffle</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.strings.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >strcasecmp</TD ></TR ></TABLE ></DIV ></BODY ></HTML >