Sophie

Sophie

distrib > PLD > ac > amd64 > media > dist > by-pkgid > dd8ef74e7a184506d40e4328053fb785 > files > 3132

php-manual-ro-20051028-1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>str_word_count</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Manual PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="String Functions"
HREF="ref.strings.html"><LINK
REL="PREVIOUS"
TITLE="str_split"
HREF="function.str-split.html"><LINK
REL="NEXT"
TITLE="strcasecmp"
HREF="function.strcasecmp.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-2"></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"
>Manual PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.str-split.html"
ACCESSKEY="P"
>Înapoi</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.strcasecmp.html"
ACCESSKEY="N"
>Înainte</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="AEN115230"
></A
><P
>    (PHP 4 &#62;= 4.3.0, PHP 5)</P
>str_word_count&nbsp;--&nbsp;
     Return information about words used in a string
    </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN115233"
></A
><H2
>Description</H2
>mixed <B
CLASS="methodname"
>str_word_count</B
> ( string string [, int format])<BR
></BR
><P
>&#13;     Counts the number of words inside <VAR
CLASS="parameter"
>string</VAR
>. 
     If the optional <VAR
CLASS="parameter"
>format</VAR
> is not specified, then 
     the return value will be an integer representing the number of words 
     found. In the event the <VAR
CLASS="parameter"
>format</VAR
> is specified, the return
     value will be an array, content of which is dependent on the 
     <VAR
CLASS="parameter"
>format</VAR
>. The possible value for the 
     <VAR
CLASS="parameter"
>format</VAR
> and the resultant outputs are listed below.
     <P
></P
><UL
><LI
><P
>&#13;        1 - returns an array containing all the words found inside the
        <VAR
CLASS="parameter"
>string</VAR
>.
       </P
></LI
><LI
><P
>&#13;        2 - returns an associative array, where the key is the numeric 
        position of the word inside the <VAR
CLASS="parameter"
>string</VAR
> and 
        the value is the actual word itself.
       </P
></LI
></UL
>
    </P
><P
>&#13;     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
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN115259"
></A
><P
><B
>Exemplu 1. Example uses for <B
CLASS="function"
>str_word_count()</B
></B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />$str </font><font color="#007700">= </font><font color="#DD0000">"Hello friend, you're<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;looking&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;good today!"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$a&nbsp;&nbsp;&nbsp;</font><font color="#007700">= </font><font color="#0000BB">str_word_count</font><font color="#007700">(</font><font color="#0000BB">$str</font><font color="#007700">, </font><font color="#0000BB">1</font><font color="#007700">);<br /></font><font color="#0000BB">$b&nbsp;&nbsp;&nbsp;</font><font color="#007700">= </font><font color="#0000BB">str_word_count</font><font color="#007700">(</font><font color="#0000BB">$str</font><font color="#007700">, </font><font color="#0000BB">2</font><font color="#007700">);<br /></font><font color="#0000BB">$c&nbsp;&nbsp;&nbsp;</font><font color="#007700">= </font><font color="#0000BB">str_word_count</font><font color="#007700">(</font><font color="#0000BB">$str</font><font color="#007700">);<br /><br /></font><font color="#0000BB">print_r</font><font color="#007700">(</font><font color="#0000BB">$a</font><font color="#007700">);<br /></font><font color="#0000BB">print_r</font><font color="#007700">(</font><font color="#0000BB">$b</font><font color="#007700">);<br />echo </font><font color="#0000BB">$c</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>&#13;       Output may look like:
      </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>Array
(
    [0] =&#62; Hello
    [1] =&#62; friend
    [2] =&#62; you're
    [3] =&#62; looking
    [4] =&#62; good
    [5] =&#62; today
)

Array
(
    [0] =&#62; Hello
    [6] =&#62; friend
    [14] =&#62; you're
    [29] =&#62; looking
    [46] =&#62; good
    [51] =&#62; today
)

6</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     See also <A
HREF="function.explode.html"
><B
CLASS="function"
>explode()</B
></A
>,
     <A
HREF="function.preg-split.html"
><B
CLASS="function"
>preg_split()</B
></A
>,
     <A
HREF="function.split.html"
><B
CLASS="function"
>split()</B
></A
>,
     <A
HREF="function.count-chars.html"
><B
CLASS="function"
>count_chars()</B
></A
>, and
     <A
HREF="function.substr-count.html"
><B
CLASS="function"
>substr_count()</B
></A
>.
    </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-split.html"
ACCESSKEY="P"
>Înapoi</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Acas&#227;</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.strcasecmp.html"
ACCESSKEY="N"
>Înainte</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>str_split</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.strings.html"
ACCESSKEY="U"
>Sus</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>strcasecmp</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>