Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Apostrophes Details »»
Apostrophes
Version: , by Boofo Boofo is offline
Developer Last Online: Jun 2012 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 08-28-2002 Last Update: Never Installs: 0
 
No support by the author.

Can anyone please help me with the following problem?

I have a user whose name ends with an apostrophe (i.e Bonet'). I want to make the name with an s like this (for ownership) Bonet's instead of Bonet''s with 2 apostrophes. I am using $userinfo[username] to get the name and if I use an 's for ownership on all other names it appears fine. I need to have it not add an apostrophe after the name if one is already there, just the s, but still keep the 's for all other names. I know it sounds confusing. I'm not sure how to pull the information out of the username variable to do this. Can anybody help?

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 08-28-2002, 11:27 AM
Scott MacVicar Scott MacVicar is offline
 
Join Date: Oct 2001
Location: Glasgow, Scotland
Posts: 1,199
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

em you could use a regexp but simpliest way is

if(substr($userinfo['username'], -1) == '\\'') {
$userinfo['username'] .= 's';
} else {
$userinfo['username'] .= '\\'s';
}
Reply With Quote
  #3  
Old 08-28-2002, 11:40 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Scott, that works perfect. As a matter of fact, it works too perfect. Is there a way I can use a variable after the users name (like $s) instead so I can just use it where I need it and not have it show up where I don't?

BTW: What is a regexp? Just curious.

Quote:
Originally posted by PPN
em you could use a regexp but simplest way is

if(substr($userinfo['username'], -1) == '\\'') {
$userinfo['username'] .= 's';
} else {
$userinfo['username'] .= '\\'s';
}
Reply With Quote
  #4  
Old 08-28-2002, 11:48 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here's what I came up with. It seems to work. Is it right? And thank you, Scott.

Quote:
if(substr($userinfo['username'], -1) == '\\'') {
$a= 's';
} else {
$a= '\\'s';
}
Reply With Quote
  #5  
Old 08-28-2002, 12:21 PM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<a href="http://php.fastmirror.com/manual/en/ref.pcre.php" target="_blank">http://php.fastmirror.com/manual/en/ref.pcre.php</a>
Reply With Quote
  #6  
Old 08-28-2002, 12:42 PM
Scott MacVicar Scott MacVicar is offline
 
Join Date: Oct 2001
Location: Glasgow, Scotland
Posts: 1,199
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

could use

Quote:
if (preg_match ("(\\'$)", $userinfo['username'])) {
$a .= 's';
} else {
$a .= '\\'s';
}
Reply With Quote
  #7  
Old 08-28-2002, 01:01 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, one last question, please. And thank you for all of the help on this. I really appreciate it.

Is there a way to do it globally for any username variable (i.e. $bbuserinfo[username] and $userinfo[username] and $post[username]) instead of having to do it individually in each area and with each different username variable?

And thank you for the link, Chen. I will check it out.
Reply With Quote
  #8  
Old 08-28-2002, 02:52 PM
Scott MacVicar Scott MacVicar is offline
 
Join Date: Oct 2001
Location: Glasgow, Scotland
Posts: 1,199
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you could just make a function

function doapostrophe($username) {
if (preg_match ("(\\'$)", $username)) {
$username .= 's';
} else {
$username .= '\\'s';
}
return $username;
}

and when you need to just use
$userinfo['username'] = doapostrophe($userinfo['username']);

something like that?
Reply With Quote
  #9  
Old 08-28-2002, 02:57 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That sounds like what I am looking for. But would there be a way to make it with the $a variable so I could just add the $a where I needed it instead of having to do the doapostrophe all over the site? And I could put this anywhere in the functions.php and it would work site wide, right? Or do I need to put it a certain place in there?

Quote:
Originally posted by PPN
you could just make a function

function doapostrophe($username) {
if (preg_match ("(\\'$)", $username)) {
$username .= 's';
} else {
$username .= '\\'s';
}
return $username;
}

and when you need to just use
$userinfo['username'] = doapostrophe($userinfo['username']);

something like that?
Reply With Quote
  #10  
Old 08-28-2002, 08:12 PM
Scott MacVicar Scott MacVicar is offline
 
Join Date: Oct 2001
Location: Glasgow, Scotland
Posts: 1,199
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You could just use

$userinfo['usernames'] = doapostrophe($userinfo['username']);

and just user $userinfo['usernames'] where you want it with the s at the end.

Correct anywhere in functions.php
Reply With Quote
Reply


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 On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:08 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04668 seconds
  • Memory Usage 2,291KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete