Current location: Hot Scripts Forums » Programming Languages » PHP » the first letter


the first letter

Reply
  #1 (permalink)  
Old 06-15-04, 06:47 AM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
Question the first letter

hi.. im trying to write a forum script just so that i maby would learn something new and so that i would have one ready when some client ask for it..
no problems so far exept that when i take table names they are all with small letters.. i would like to replace the first letter with same but BIG version of it..
i mean the first letter.. not spaces ond/or numbers
anyone have the code snipped ready?


thx 4 all help
Wille
Reply With Quote
  #2 (permalink)  
Old 06-15-04, 07:37 AM
Worm's Avatar
Worm Worm is offline
Newbie Coder
 
Join Date: Jun 2004
Location: Germany, Frankfurt am Main
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by <?Wille?>
hi.. im trying to write a forum script just so that i maby would learn something new and so that i would have one ready when some client ask for it..
no problems so far exept that when i take table names they are all with small letters.. i would like to replace the first letter with same but BIG version of it..
i mean the first letter.. not spaces ond/or numbers
anyone have the code snipped ready?


thx 4 all help
Wille
Hi !

Either I just dont know the code you are talking about or I think there is no code for changing the first letter BIG, because the MySQL Server will rename the first letter of your tablename even if you create a new table. If you try

CREATE TABLE `Errorhandling` (
`ID` int(11) NOT NULL auto_increment,
`errno` varchar(100) NOT NULL default '0',
`errtext` varchar(255) NOT NULL default '',
PRIMARY KEY (`ID`)
) TYPE=MyISAM;

the MySQL Server will save it as `errorhandling`...

:?
Reply With Quote
  #3 (permalink)  
Old 06-15-04, 07:52 AM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Worm
Hi !

Either I just dont know the code you are talking about or I think there is no code for changing the first letter BIG, because the MySQL Server will rename the first letter of your tablename even if you create a new table. If you try

CREATE TABLE `Errorhandling` (
`ID` int(11) NOT NULL auto_increment,
`errno` varchar(100) NOT NULL default '0',
`errtext` varchar(255) NOT NULL default '',
PRIMARY KEY (`ID`)
) TYPE=MyISAM;

the MySQL Server will save it as `errorhandling`...

:?
actually.. i want a php code that changes the strings first letter.. the function i think should be used is "eregi_replace" but i didnt understand anything about their examples when trying to figure out the rigth arguments from php manual
Reply With Quote
  #4 (permalink)  
Old 06-15-04, 07:57 AM
Worm's Avatar
Worm Worm is offline
Newbie Coder
 
Join Date: Jun 2004
Location: Germany, Frankfurt am Main
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by <?Wille?>
actually.. i want a php code that changes the strings first letter.. the function i think should be used is "eregi_replace" but i didnt understand anything about their examples when trying to figure out the rigth arguments from php manual
You want to change the first letter of which string ? Pls make an example...

Some code that might help you:

PHP Code:

function change_first($c_string)

{
  if(
ord($c_string[0]) >= 97 || ord($c_string[0]) <= 122)
  {
    
$temp ord($c_string[0]) - 32;
    
$c_string[0] = chr($temp);

    return 
$c_string;
  }

How about this ?

Last edited by Worm; 06-15-04 at 08:04 AM.
Reply With Quote
  #5 (permalink)  
Old 06-15-04, 08:05 AM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Worm
You want to change the first letter of which string ? Pls make an example...
well.. i said i was doing a forum.. so basicly a table is a thread.. or well thats my easyest logic solution.. so when im trying to list the threads i logicly use mysql_list_tables and put them in a table.. but becourse mysql renames and makes all letters small i want to replace 1st letter with the Big version.

PHP Code:

// inside a loop

// alot before
$tablename "general discussion or something"// not this easy in my code
// some more
// here the change before i echo it
echo("<td>$tablename</td>"); 
Reply With Quote
  #6 (permalink)  
Old 06-15-04, 08:15 AM
Worm's Avatar
Worm Worm is offline
Newbie Coder
 
Join Date: Jun 2004
Location: Germany, Frankfurt am Main
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by <?Wille?>
well.. i said i was doing a forum.. so basicly a table is a thread.. or well thats my easyest logic solution.. so when im trying to list the threads i logicly use mysql_list_tables and put them in a table.. but becourse mysql renames and makes all letters small i want to replace 1st letter with the Big version.

PHP Code:

// inside a loop

// alot before
$tablename "general discussion or something"// not this easy in my code
// some more
// here the change before i echo it
echo("<td>$tablename</td>"); 
Did you have a look at the function above ?
Reply With Quote
  #7 (permalink)  
Old 06-16-04, 05:22 AM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Worm
Did you have a look at the function above ?
no actually.. didnt notice it..
Reply With Quote
  #8 (permalink)  
Old 06-16-04, 05:26 AM
Worm's Avatar
Worm Worm is offline
Newbie Coder
 
Join Date: Jun 2004
Location: Germany, Frankfurt am Main
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by <?Wille?>
no actually.. didnt notice it..
did it help you ?
Reply With Quote
  #9 (permalink)  
Old 06-16-04, 05:32 AM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
so now i tryed that code.. unfortunally it didt work.. it didt change the string in any way.. then ofcourse just so that it would not be too easy for you who try to help me the code im looking for should also be able to change scandinavian letters å ä ö (&aring; &auml; &ouml; in html if someone would need them)
Reply With Quote
  #10 (permalink)  
Old 06-16-04, 06:32 AM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
stupid me

stupid me.. ofcourse it doesint do anything when i dont call the function..
we are doing some progress..
so this is the code right now:
PHP Code:

if(ord($tab) >= 97 && ord($tab) <= 122) { // must be && not ||.. its always one of them

    
$temp ord($tab) - 32
    
$tab chr($temp); 

but... problem is.. table name is "general talk" but now i get only "G"..
suggestions?
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
make money w/ just 6 dollars-legitimate! marilpowe3 General Advertisements 0 02-07-04 02:16 AM


All times are GMT -5. The time now is 05:02 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.