vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Trimming Row output for display (https://vborg.vbsupport.ru/showthread.php?t=69276)

Jolten 09-10-2004 01:08 AM

Trimming Row output for display
 
Hi,

I've got a query and string to display some information and usernames. One problem I'm having is long usernames. I'd like to truncate usernames longer than 8 characters to 6 characters then add ... after it. I can't seem to get this working in my while loop. Any help would be appreciated.

here's what I've got right now inside the while loop
Code:

if (strlen($row2->strUsrid) > 8)
                                                                {
                                                                        $Winner = substr($row2->strusrid, 0, 8 - 2) . '..';
                                                                }


Colin F 09-10-2004 03:59 AM

why are you doing 8-2 and not just 6?

Jolten 09-10-2004 04:14 AM

well 6 wasn't working.

Modin 09-14-2004 02:22 AM

is Usrid the variable you want to be trimming? It would seem intuitive to be trimming a variable called Username (or whatever you store it in).

Unless of course you have the username stored in that variable.

Brad 09-14-2004 03:01 AM

Use this:

PHP Code:

          // is $username longer then 8 char?
        
if (strlen($username) > 8)
        {
            
// long username, strip it down to 6 char
            
$username substr($username06);
            
// append '....' to the end of the username
            
$username .= '....';
        } 


Jolten 09-14-2004 04:03 AM

Thanks Brad.loo. That worked perfectly with the substituted string I needed to trim.

(and yes it was strusrid it's a custom table not native to vb3.)


All times are GMT. The time now is 09: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.00955 seconds
  • Memory Usage 1,721KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete