GetDotted Domains

Viewing Thread:
"How would I..."

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Thu 19/05/05 at 08:15
Regular
"Pouch Ape"
Posts: 14,499
I'm building a CMS at the moment, and it's my first real attempt at using the image library functions. I'm going to use a source image, resize and resample it, and output in custom dimensions. Simple enough. But I'm also building into the system a small BBoard-style text formatting system (like the square bracket one on here), and I want the user to be able to put [IMG=x] - 'x' being the image ID, then the script scans the string, pulls out that text, and lets me use x as a variable to find the corresponding image. I'm probably being a right dunce, and there's probably a simple answer, so any help would be appreciated, cheers!


EDIT: Hmmm, found the function "stristr(haystack, needle)", which might do what I'm after.
Thu 19/05/05 at 20:45
Regular
"NULL"
Posts: 1,384
The function you're probably after is eregi_replace(). The PHP manual is quite good on that function - it tells you how to do the regular pattern you need to use.

I'm crap with pattern matching, so I can't give you a specific code for it, but the jist is you say "The tag starts [IMG= and ends with a ], so extract the bit in the middle".
Thu 19/05/05 at 15:02
Regular
"Pouch Ape"
Posts: 14,499
Explain. Please. And not in the form of a riddle, Dungeon Master.
Thu 19/05/05 at 14:43
Regular
"Devil in disguise"
Posts: 3,151
Regular expressions are the way to go with problems like this.
Thu 19/05/05 at 08:31
Regular
"Pouch Ape"
Posts: 14,499
$image_id = substr($content, strrpos($content, '[IMG=') + 1);
$image_id = str_replace("]", "", $image_id);

That'll work, right?
Thu 19/05/05 at 08:15
Regular
"Pouch Ape"
Posts: 14,499
I'm building a CMS at the moment, and it's my first real attempt at using the image library functions. I'm going to use a source image, resize and resample it, and output in custom dimensions. Simple enough. But I'm also building into the system a small BBoard-style text formatting system (like the square bracket one on here), and I want the user to be able to put [IMG=x] - 'x' being the image ID, then the script scans the string, pulls out that text, and lets me use x as a variable to find the corresponding image. I'm probably being a right dunce, and there's probably a simple answer, so any help would be appreciated, cheers!


EDIT: Hmmm, found the function "stristr(haystack, needle)", which might do what I'm after.

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Excellent support service!
I have always found the support staff to provide an excellent service on every occasion I've called.
Ben
LOVE it....
You have made it so easy to build & host a website!!!
Gemma

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre
Feedback Close Feedback

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.