TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,973
  • Latest: NonStop
Stats
  • Total Posts: 196,234
  • Total Topics: 21,353
  • Online today: 606
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 519
  • Total: 520
  • @rjen

Exploding Fun

Started by Thalov, August 23, 2007, 02:52:44 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Thalov

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()?

G6Cad

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.

Thalov

This is via a php article done in TP - but if I should go to the SMF boards - lemme know

G6Cad

No, if it is a function for the TP article system it is indeed a valid support question for us here :)   

This website is proudly hosted on Crocweb Cloud Website Hosting.