Sample code for 30+ languages & platforms
PHP Extension

StringBuilder ReplaceWord

Demonstrates the ReplaceWord method.

Chilkat PHP Extension Downloads

PHP Extension
<?php

include("chilkat.php");

$sb = new CkStringBuilder();
$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
print $sb->getAsString() . "\n";

?>