MathCurvesSurfacesWallpaper GroupsGallerySoftwarePOV-Ray
ProgramingLinuxPerl PythonHTMLCSSJavaScriptPHPJavaEmacsUnicode ♥
Web Hosting by 1&1

PHP: Basic String Operations

Xah Lee,

Strings can be joined by the period “.” symbol.

<?php
$a = "this" . " that";
echo $a; // prints “this that”
?>

String Operators

Substring extraction is done using the function “substr”. The form is: “substr( $myStr, $startIndex, $length)”. String index starts with 0.

<?php
$a = "once upon a time";
echo substr($a,0,4); // prints “once”
?>

substr

Length of the string is “strlen()”.

<?php
$a = "once";
echo strlen($a); // prints 3
?>

strlen

blog comments powered by Disqus
2007-11