Jump to content


Photo

Truncate string to one char for small calendar display


  • Please log in to reply
3 replies to this topic

#1 LBPP

LBPP
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 11 July 2006 - 06:51 PM

I have a php script that shows a mini calendar on my site http://www.LBPP.net/geeklog, right now the days are abbreviated to 3 chars ie "Sun" because of this it is making the calendar too wide and is being cut off. I need to truncate the output of this script to just one char so its like "S" "M" "T" "W" "T" "F" "S". This is what i have:

  
// Main Calendar
 $BlockDisplay .= "</td></tr><tr>";

     for ($i = 0; $i < 7; $i++)
     {
         $BlockDisplay .= "<td align='center' valign='top' width='14%'
 class='mycalTitle'><font size='1'><b>"
             . ucfirst(strftime("%a", $firstdaytodisplay + ($i *
 _MYCAL_DAY_)))
             . "</b></font></td>";
    }

I did not write this code and am only trying to modify it, but my PHP skills are limited. Any insight in the direction i need to take would be much appreciated.

#2 LBPP

LBPP
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 11 July 2006 - 07:09 PM

i know this is easy... im just stupid, can no one give me a quick solution?

#3 ShogunWarrior

ShogunWarrior
  • Members
  • PipPipPip
  • Advanced Member
  • 528 posts
  • LocationIreland

Posted 11 July 2006 - 07:32 PM

ucfirst(strftime("%a", $firstdaytodisplay + ($i *
_MYCAL_DAY_)))

Replace with:
substr(ucfirst(strftime("%a", $firstdaytodisplay + ($i *
_MYCAL_DAY_))),0,1)

<a href="http://www.daviddora...nmedia.com/">My New Site/Blog</a> | <a href="http://www.daviddora...m/check/">Check your page for broken links/images/scripts</a>

Zend Certified Engineer
Follow me on Twitter: http://twitter.com/davidd

#4 LBPP

LBPP
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 11 July 2006 - 07:41 PM

YAY!!! thanks ShogunWarrior!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users