Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    North East England
    Posts
    853
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Restricting instances in data

    I'm making a small message board where peeps can buy/sell or place wanted ads, being incapable of installing 3rd party scripts I'm coding it myself ...actually learnin' stuff too

    Two things:

    1) spaces in data, how do I keep 'em as spaces rather than regurgitating them as %20 or whatever?

    2) I'd like to restrict smilie useage in a similar way to this site, limiting to 8 or so per post, my smilie code is like so: [smilie=1], [smilie=2] and so on.
    [+] Computer/PC issues [+] Silverpaw3D
    ------------------------------------------------
    Never buy a dwarf with learning disabilities...

    ...it's not big, and it's not clever.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't get the part with the %20 as substitutes for spaces. How does that happen - do you treat the data with urlencode()?

    As for the instances of smiley code, you have a look at substr_count(), I think that does exactly what you want.
    http://za2.php.net/manual/en/function.substr-count.php

    Use it like

    PHP Code:
    $numberOfSmileys substr_count($data"[smilie=");
    if (
    $numberOfSmileys 8) {
       echo 
    "that's too much, I'm afraid.";



  •  

    Posting Permissions

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