Be a Supporter!

php help

  • 322 Views
  • 6 Replies
New Topic Respond to this Topic
JeremysFilms
JeremysFilms
  • Member since: Feb. 18, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
php help 2006-07-23 11:35:42 Reply

Setting:
I have a text area. When you submit the form to PHP, it takes the text and converts each letter into an image by retrieving an image file that corresponds to the letter being dealt with.

Problem:
I tried to make the script take line breaks and just insert a <br> tag. The problem I'm having with this is that it does insert the <br> tag correctly, but it also inserts an image tag before this <br> (literally with the line break):
<img src="
.gif"><br>

The Snippet of Code:
$output .= '';
for($i=0; $i<count($letters); $i++){
$letters[$i] = preg_replace($pattern, $replace, $letters[$i]);
if($letters[$i] == ' '){
$output .= '&nbsp;';
}else{
if($letters[$i] == "\n"){
$output .= '<br>';
}else{
$output .= '<img src="'.$letters[$i].'.gif">';
}
}
}

Notes about Snippet:
- preg_replace() function is being used to replace puntuation characters with other names since I am not using punctuation symbols as file names.

- I'm not using elseif() because I decided to try testing this with just else but (as I predicted) it made no difference so I presume I'll change it back later on.

May I have a Solution?

CaptinChu
CaptinChu
  • Member since: Sep. 11, 2005
  • Offline.
Forum Stats
Member
Level 15
Blank Slate
Response to php help 2006-07-23 11:50:33 Reply

I think you have to do "if else" instead of just else. But I'm not completely sure. *is waiting for a php professional to tell him what actually needs to be done*

JeremysFilms
JeremysFilms
  • Member since: Feb. 18, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to php help 2006-07-23 11:55:09 Reply

At 7/23/06 11:50 AM, CaptinChu wrote: I think you have to do "if else" instead of just else. But I'm not completely sure. *is waiting for a php professional to tell him what actually needs to be done*

1) It's called elseif()
2) If you read the notes in my post pointed out clearly with bold and underlined text, you would know why I'm simply using else's

I hate when people don't read.

Jcrypt
Jcrypt
  • Member since: Aug. 23, 2005
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to php help 2006-07-23 12:19:00 Reply

This may be TOTALLY out there but iv'e hadd code mess up by having constants set like that ( .= ) try to just have a basic assigning symbol. ( = ) 'obviously :P' and good luck again it has made a difference for me post back and let me know i'll look at it closer when i get home sorta ran outta time here :P Good Luck. ~James

JeremysFilms
JeremysFilms
  • Member since: Feb. 18, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to php help 2006-07-23 12:21:28 Reply

At 7/23/06 12:19 PM, Jcrypt wrote: This may be TOTALLY out there but iv'e hadd code mess up by having constants set like that ( .= ) try to just have a basic assigning symbol. ( = ) 'obviously :P' and good luck again it has made a difference for me post back and let me know i'll look at it closer when i get home sorta ran outta time here :P Good Luck. ~James

What????

Jcrypt
Jcrypt
  • Member since: Aug. 23, 2005
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to php help 2006-07-23 12:22:14 Reply

Actually hooks WOULD be less on your RAM and would be smoother but in C++ you could whip up a quick switch() statment and hide the console to run in the BG and on startup with no more than roughly 50-70 lines of code (26 being just the switch statement for the alphabet part)

Jcrypt
Jcrypt
  • Member since: Aug. 23, 2005
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to php help 2006-07-23 12:23:53 Reply

omg sorry for the above post I thought I was in a different thread that post was in reference to http://www.newground../topic.php?id=531379