Sample code for 30+ languages & platforms
PHP Extension

StringBuilder GetNth

Demonstrates the GetNth method.

Chilkat PHP Extension Downloads

PHP Extension
<?php

include("chilkat.php");

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

$sb = new CkStringBuilder();
$sb->Append('red,blue,\'green,purple\',,yellow');

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

// 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";

?>