Log in

View Full Version : PHP array



hemi519
07-22-2011, 05:41 AM
Hi All,

I just want to know if thr is any function for the follwoing

$Name = dynamicdrive;

Now i want the 6th character alone should become capital. If it is possible help me out

bluewalrus
07-22-2011, 01:20 PM
No function that I know of but


<?php
$Name = "dynamicdrive";
$become = substr($Name, 0, 4) . strtoupper(substr($Name, 5, 1)) . substr($Name, 6);
?>

should do it. I also don't understand the title of this, is there something to do with arrays?

traq
07-23-2011, 05:44 AM
you can access strings by character offset (http://us3.php.net/manual/en/language.types.string.php#language.types.string.substr), but they're still strings, not arrays.

$str = 'dynamicdrive';
$str[0] = strtoupper($str[0]);
$str[7] = strtoupper($str[7]);
print $str; // prints "DynamicDrive"