Jump to content

Simple PHP String Operation


eggerda

Recommended Posts

<?php
// Our name
$name = "john Doe";

// Seperate the name at the space, this will
// give us an array with 2 values
$parts = explode($name);

// ucfirst makes the first character uppercase
echo ucfirst($parts[0]);
?>

 

Should be:

 

<?php
// Our name
$name = "john Doe";

// Seperate the name at the space, this will
// give us an array with 2 values
$parts = explode(" ", $name);

// ucfirst makes the first character uppercase
echo ucfirst($parts[0]);
?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.