String manipulation is probably one of PHP's biggest strengths, as it offers a handful of functions to perform a variety of operations. Even when almost every need can be fulfilled by using PHP's core methods, some forms of string manipulation may prove troublesome.
Note
To find out more about some of PHP's core string methods see http://php.net/manual/en/ref.strings.php.
CakePHP offers a utility class named String
to help us deal with strings. This recipe introduces the class and its few, yet useful set of methods.
We need a controller to use as placeholder for our code. Create a file named examples_controller.php
and place it in your app/controllers
folder, with the following contents:
<?php class ExamplesController extends AppController { public $uses = null; public function index() { $this->_stop(); } ?>