TinyPortal

Development => Support => Topic started by: Thalov on August 23, 2007, 02:52:44 PM

Title: Exploding Fun
Post by: Thalov on August 23, 2007, 02:52:44 PM
So I have a form for users to enter information in to. Instead of having the users fill two fields of data (one with data they want to show and one with the all the previous data and more data that they want to remain hidden) I'd like to give them the ability to put some kind of [tag] <tag> around the bit of information they want to show to the public.

But so far my results have I've only managed to lay a giant goose egg.

I have the function below inside the file that sends the data to the DB. Let me know if you need to see more of the code. However this seems to be the point where it's failing at...

Reveal Function
function reveal($string2){
$begin = "<r>";
$end = "</r>";
$first_explode = explode($string2, $begin);

for ($j = 1; $j <= sizeof($first_explode); $j += 1){
$use_this[$j-1] = $first_explode[$j];
}
$final = '';
for ($i = 0; $i < sizeof($use_this); $i += 1){
$current[$i] = explode($use_this[$i], '</r>');
$final = "$final $current[0]";
}
// $return_this = join('',$final);

return $final;
}


After some playing around and testing I've noticed that $first_explode is only getting an array with one element that's filled with " ".

The data I'm entering in to test this is:
I don't want to see <r>I would like
to see this content</r> I don't want to see

I would expect with this entry I would yield two elements for $first_explode. One with "I don't want to see " and the second with <r>I would like to see this content</r> I don't want to see".

What can I do to fix this? Perhaps use something other than explode()?
Title: Re: Exploding Fun
Post by: G6Cad on August 23, 2007, 03:21:18 PM
Is this some sort of a new forum function you are trying to get to work ? If so it's more a coding matter for SMF to help you with.
Title: Re: Exploding Fun
Post by: Thalov on August 23, 2007, 03:25:20 PM
This is via a php article done in TP - but if I should go to the SMF boards - lemme know
Title: Re: Exploding Fun
Post by: G6Cad on August 23, 2007, 03:26:07 PM
No, if it is a function for the TP article system it is indeed a valid support question for us here :)