Quantcast
Channel: Different PHP Blog » PHP
Browsing latest articles
Browse All 3 View Live

PHP array length

To get PHP array length use following: $arr = array(1, 2, 3); echo count($arr); // will output 3 If you need to check if non-associative array is enough long, use: if (isset($arr[5])) { } instead of:...

View Article


PHP explode foreach

PHP explode() in combination with foreach is a nice way to format comma separated values from string. Consider following code: $str = "alfa, bravo, charlie"; foreach (explode(',', $str) as $val) { echo...

View Article


PHP capitalize first letter

To capitalize only first letter in word use PHP function ucfirst(): echo ucfirst('anaCONda').'<br>'; echo ucfirst('AnaCONda'); This will output: AnaCONda AnaCONda To capitalize all word first...

View Article
Browsing latest articles
Browse All 3 View Live