PHP handleiding

PHP TUIS PHP Inleiding PHP installeer PHP sintaksis PHP opmerkings PHP veranderlikes PHP Echo / Druk PHP datatipes PHP Strings PHP-nommers PHP Wiskunde PHP konstante PHP-operateurs PHP As...Anders...Elseif PHP skakelaar PHP-lusse PHP funksies PHP-skikkings PHP Superglobals PHP RegEx

PHP- vorms

PHP-vormhantering PHP-vorm validering PHP-vorm word vereis PHP-vorm URL/e-pos PHP-vorm voltooi

PHP Gevorderd

PHP datum en tyd PHP sluit in PHP-lêerhantering PHP-lêer oop/lees PHP-lêer skep/skryf PHP-lêer oplaai PHP-koekies PHP-sessies PHP filters PHP-filters Gevorderd PHP-terugbelfunksies PHP JSON PHP-uitsonderings

PHP OOP

PHP Wat is OOP PHP Klasse/Objekte PHP Konstrukteur PHP vernietiger PHP Toegangswysigers PHP erfenis PHP konstante PHP Abstrakte Klasse PHP-koppelvlakke PHP eienskappe PHP statiese metodes PHP Statiese Eienskappe PHP naamruimtes PHP Iterables

MySQL- databasis

MySQL-databasis MySQL Connect MySQL Skep DB MySQL Skep tabel MySQL Voeg data in MySQL Kry Laaste ID MySQL Voeg veelvuldige in MySQL voorberei MySQL Kies Data MySQL Waar MySQL Bestel deur MySQL verwyder data MySQL-opdateringsdata MySQL-limietdata

PHP XML

PHP XML-ontleders PHP SimpleXML-ontleder PHP SimpleXML - Kry PHP XML Expat PHP XML DOM

PHP - AJAX

AJAX Intro AJAX PHP AJAX-databasis AJAX XML AJAX Live Search AJAX-peiling

PHP voorbeelde

PHP voorbeelde PHP samesteller PHP vasvra PHP Oefeninge PHP-sertifikaat

PHP- verwysing

PHP Oorsig PHP Skikking PHP-kalender PHP datum PHP gids PHP fout PHP-uitsondering PHP lêerstelsel PHP filter PHP FTP PHP JSON PHP sleutelwoorde PHP Libxml PHP-pos PHP Wiskunde PHP Diverse PHP MySQLi PHP-netwerk PHP-uitsetbeheer PHP RegEx PHP SimpleXML PHP-stroom PHP-string PHP veranderlike hantering PHP XML-ontleder PHP zip PHP Tydsones

PHP str_word_count() Funksie

❮ PHP-stringverwysing

Voorbeeld

Tel die aantal woorde wat in die string "Hallo Wêreld!" gevind word:

<?php
echo str_word_count("Hello world!");
?>

Definisie en gebruik

Die str_word_count() funksie tel die aantal woorde in 'n string.


Sintaksis

str_word_count(string,return,char)

Parameterwaardes

Parameter Description
string Required. Specifies the string to check
return Optional. Specifies the return value of the str_word_count() function.

Possible values:

  • 0 - Default. Returns the number of words found
  • 1 - Returns an array with the words from the string
  • 2 - Returns an array where the key is the position of the word in the string, and value is the actual word
char Optional. Specifies special characters to be considered as words.


Tegniese besonderhede

Terugkeerwaarde: Wys 'n getal of 'n skikking, afhangende van die gekose terugkeerparameter
PHP weergawe: 4.3.0+
Veranderinglog: Die char parameter is bygevoeg in PHP 5.1

Meer voorbeelde

Voorbeeld

Gee 'n skikking terug met die woorde uit die string:

<?php
print_r(str_word_count("Hello world!",1));
?>

Voorbeeld

Gee 'n skikking terug waar die sleutel die posisie van die woord in die string is, en waarde die werklike woord is:

<?php
print_r(str_word_count("Hello world!",2));
?>

Voorbeeld

Sonder en met die char parameter:

<?php
print_r(str_word_count("Hello world & good morning!",1));
print_r(str_word_count("Hello world & good morning!",1,"&"));
?>

❮ PHP-stringverwysing