Volg de onderstaande video om te zien hoe je onze site als web-app op je startscherm installeert.
Opmerking: Deze functie is mogelijk niet beschikbaar in sommige browsers.
function first_words($string,$cwords)
{
$len=0;
for($i=0;$i<$cwords;$i++)
{
$len = strpos($string,' ',$len);
}
if($len===false)
{
return $string;
}
else
{
return substr($string,0,$len);
}
}
. Der bestond denk ik efficiëntere methode om de zoveelste spatie te vinden, ma kherinner me et nie meer
.function first_words($string,$cwords)
{
if($cwords>=str_word_count) return $string;
$posarray = array_flip(str_word_count($string,2));
$words = str_word_count($string,1);
$len=$posarray[$words[$cwords]];
f
return substr($string,0,$len);
}
function first_words($string,$cwords){
if($cwords>=str_word_count) return $string;
$posarray = array_flip(str_word_count($string,2));
$words = str_word_count($string,1);
$len=$posarray[$words[$cwords]];
return substr($string,0,$len);
}

function first_words($string,$cwords){
if($cwords >= str_word_count($string)) return $string;
$posarray = array_flip(str_word_count($string,2));
$words = str_word_count($string,1);
$len=$posarray[$words[$cwords]];
return substr($string,0,$len);
}

nja, kweet niet, kheb dit gauw gecode hier op het forum toen je erom vroeg. Ik kap meestal af na x aantal tekens en dan de eerste spatie, iets "complexter" read more algoritme dusbt belgium zei:ik neem aan dat het dit moet zijn?
maar dan werkt het niet![]()
geen syntax errors ofzo maar ik krijg gewoon weer het hele bericht te zien als ik bevoorbeeld maar 5 woorden wil![]()
.<?php
function first_words($string,$cwords){
if($cwords >= str_word_count($string)) return $string;
$posarray = array_flip(str_word_count($string,2));
$words = str_word_count($string,1);
$len=$posarray[$words[$cwords]];
return substr($string,0,$len);
}
echo first_words("dit is een test",2);
?>
.
).yuptaLa. zei:PHP:function firstWords($string, $amount){ $words = explode(' ', $string); $words = array_slice($words, 0, $amount); $newstr = implode(' ', $words); return $newstr; } echo firstWords("Foo to the bar yo fo shizzle ma nizzle", 5);
Nee ?![]()
, zal nog +/- snelste zijn als uw tekst niet extreem lang wordt
.