Babita Bhandari Babita Bhandari - 1 year ago 136
MySQL Question

Show database table column names as pascal case

I have create a table in phpmyadmin where i add the column names as first_name,last_name.When i use the command to show column names from table in database it display columns as first_name.I want to display my column names like this First Name.Can you please tell me how to show column names in pascal case.

Answer Source

This code converts some_text to Some Text:

$before = array('first_name', 'last_name', 'something');

$after = array();
foreach($before as $v){
    $after[] = implode(' ', array_map('ucfirst', explode('_', $v)));


    [0] => First Name
    [1] => Last Name
    [2] => Something

And another way of doing the same:

// .. foreach ..
$after[] = ucwords(implode(' ', explode('_', $v)));
// code

The output is the same as before.

Note that I don't know how you have those values nor how you are showing them.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download