Sample code for 30+ languages & platforms
PHP

StringBuilder ReplaceWord

Demonstrates the ReplaceWord method.

Chilkat PHP Downloads

Chilkat2 PHP
<?php

use Chilkat2\StringBuilder;

$sb = new StringBuilder();
$sb->Append('forest, lumber, lumberjack, jack, timberland');

// The ReplaceWord method replaces word occurances.

// For example:
$numReplacements = $sb->ReplaceWord('lumber', 'timber');
$numReplacements = $sb->ReplaceWord('jack', 'joe');

// The string content is now:
// forest, timber, lumberjack, joe, timberland
echo $sb->GetAsString(), "\n";