i have the folowing code that gives me the first letter of each word.

$string = $rowec['doopnamen'];
                    $punt =".";
$words = explode(" ", $string);
$doopnamen = " ";
foreach ($words as $value) {

    $doopnamen .= substr($value, 0, 1);

}

But how can i get a dot after each letter ?
Thanks in advice John

Recommended Answers

Not tested, but try:

$words = explode(',', implode('.,', $string));

this gives you an array again, if you want just a string then use just implode('.', $string).

Edit___
Or:

foreach($words as $value) { $doopnamen .= substr($value, 0, 1).'.'; }

so, if $string:

Jump to Post

All 2 Replies

Not tested, but try:

$words = explode(',', implode('.,', $string));

this gives you an array again, if you want just a string then use just implode('.', $string).

Edit___
Or:

foreach($words as $value) { $doopnamen .= substr($value, 0, 1).'.'; }

so, if $string:

$string = 'alfa beta';

from the loop you get a.b. It was this you needed? Bye!

Thanks for your help Cereal

$words = explode(',', implode('.,', $string));

Gives an error

But

foreach($words as $value) { $doopnamen .= substr($value, 0, 1).'.'; }

Works great.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.