PHP
Chilkat2 PHP
StringBuilder RemoveAfterFinal
Demonstrates the StringBuilder.RemoveAfterFinal method.The GetBefore method was added in Chilkat v9.5.0.77
Chilkat PHP Downloads
<?php
use Chilkat2\StringBuilder;
$sb = new StringBuilder();
$sb->Append('abc::def::ghi');
// Replace the 1st occurrence of a substring with another string.
try {
$sb->ReplaceFirst('::', '-');
$bFound = true;
} catch (\Chilkat2\Exception $e) {
$bFound = false;
}
echo 'bFound = ', ($bFound ? 'true' : 'false'), "\n";
echo 'sb contains: ', $sb->GetAsString(), "\n";
// Output is:
// bFound = True
// sb contains: abc-def::ghi