View Full Version : Restricting instances in data

07-22-2002, 03:19 AM
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 :rolleyes::D ...actually learnin' stuff too :eek:

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.

07-22-2002, 01:28 PM
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.

Use it like

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