Sample code for 30+ languages & platforms
PHP ActiveX

StringBuilder GetNth

Demonstrates the GetNth method.

Chilkat PHP ActiveX Downloads

PHP ActiveX
<?php

// The GetNth method is handy for getting parts from delimited strings.
// For example:

$sb = new COM("Chilkat.StringBuilder");
$sb->Append('red,blue,\'green,purple\',,yellow');

$delimiterChar = ',';
$exceptDoubleQuoted = 1;
$exceptEscaped = 1;

// Prints "[red]"
print '[' . $sb->getNth(0,$delimiterChar,$exceptDoubleQuoted,$exceptEscaped) . ']' . "\n";

// Prints "[blue]"
print '[' . $sb->getNth(1,$delimiterChar,$exceptDoubleQuoted,$exceptEscaped) . ']' . "\n";

// Prints "[green,purple]"
print '[' . $sb->getNth(2,$delimiterChar,$exceptDoubleQuoted,$exceptEscaped) . ']' . "\n";

// Prints "[]"
print '[' . $sb->getNth(3,$delimiterChar,$exceptDoubleQuoted,$exceptEscaped) . ']' . "\n";

// Prints "[yellow]"
print '[' . $sb->getNth(4,$delimiterChar,$exceptDoubleQuoted,$exceptEscaped) . ']' . "\n";

// Prints "[]"
print '[' . $sb->getNth(5,$delimiterChar,$exceptDoubleQuoted,$exceptEscaped) . ']' . "\n";

?>