SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    building buttons

    hello

    how do i search a string for a list of different characters
    for the moment i am using this which works, but i want to be able to replace $searchfor being one character as many different characters ie "m, w, h"

    >$title = ("my name");
    >$searchfor = ("m");
    >$answer = substr_count($title, $searchfor);

    the purpose of this is to be able to make an image button in php with a string thats passed to it, the size in width that is needed.


    thanks in advance!
    a+
    Garrett

  2. #2
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Take a look at the count_chars function: http://www.php.net/manual/en/function.count-chars.php
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  3. #3
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have but trying to thinking of an easier way to figure out how many pixels wide each letter, number or symbol is without having to insert a if condition for each one!

    i notice in the php manual it says...

    >ImageTTFText() returns an array with 8 elements >representing four points making the bounding >box of the text. The order of the points is upper >left, upper right, lower right, lower left

    which should be what i need.
    however i fail to see how to use this as you have to set the size of the image before you can write on it?? bit of a chicken and egg situation.

    any ideas?

    Garrett


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •