vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Hey (https://vborg.vbsupport.ru/showthread.php?t=63342)

Owen 04-02-2004 01:29 PM

Hey
 
I am currently making a gallery and have come a long way.

What I want to do now is:
$title=$name

where $name is file-with-dashes.jpg

Now I want $title to be $name with dashes replaced with spaces and .jpg removed.

I have shortened text before but never chopped off the ending...

NTLDR 04-02-2004 01:38 PM

PHP Code:

$title substr(str_replace('-'' '$name), 0, -4); 

Should do it.

Owen 04-02-2004 01:39 PM

thanks man! I'll post a link to the gallery here once it's done.

Boofo 04-02-2004 01:44 PM

Quote:

Originally Posted by NTLDR
PHP Code:

$title substr(str_replace('-'' '$name), 0, -4); 

Should do it.

I'm curious, what is the 0 and the -4 in this code for?

NTLDR 04-02-2004 01:45 PM

The 0 is the start position and the -4 is the end position, ie chop 4 characters off the end.

http://uk.php.net/substr

Boofo 04-02-2004 01:47 PM

Oh, ok, you mean like chop off the .jpg or .gif?

NTLDR 04-02-2004 01:50 PM

Yep :)

Boofo 04-02-2004 01:57 PM

Thanks! See? Even an old dog can learn new tricks. ;)

Owen 04-02-2004 02:09 PM

What if I want to display the first word that comes before a dash?

like:
file-with-dashes.jpg = file

NTLDR 04-02-2004 02:10 PM

PHP Code:

$parts explode('-'$name);
$file $parts[0]; 



All times are GMT. The time now is 06:28 AM.

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.01179 seconds
  • Memory Usage 1,735KB
  • 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
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete