Friday, November 25, 2011

CharAt in PHP

If you want to get a character from a string at a given index using PHP, first thing which come in mind to most javascript or java developers is charAt() function or method, but in PHP there is not such method. Which is a surprise to me, i googled for a while and find out no such methods exist, however we can very easily create one.

so here it is.
    public function charAt($string,$index){
        return $string{$index};
    }
That is all folks!

0 comments:

Post a Comment

 

Blog Info

A Pakistani Website by Originative Systems

Total Pageviews

Tutorial Jinni Copyright © 2015 WoodMag is Modified by Originative Systems