![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
quick simple php question
Say that I have some data in my sql database that reads
"hello how are you" How do I make it echo on the same line so it displays? "Hello how are you" Here is my current code to echo it = <?php print $hi->hello ?> |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
<&(©¿©)&>
Industry Role:
Join Date: Jul 2002
Location: Chicago
Posts: 47,882
|
obviously remove new line characters...
![]()
__________________
Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000 Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager ![]() Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
howdy woj, im extremely new to php, tried googling it but was a bit confusing. can anyone tell me what I should replace this with? I can't modify the db at all
<?php print $hi->hello ?> |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Too lazy to set a custom title
Industry Role:
Join Date: Sep 2005
Location: Springfield
Posts: 13,826
|
you need to remove new lines (or <br> tags) from that string
new lines $x = str_replace(array("\r\n","\r"),"",$x); tags (will strip all) $x = strip_tags($x); and then echo it
__________________
Make a bank with Chaturbate - the best selling webcam program ![]() ![]() ![]() Ads that can't be block with AdBlockers !!! /// Best paying popup program (Bitcoin payouts) !!! PHP, MySql, Smarty, CodeIgniter, Laravel, WordPress, NATS... fixing stuff, server migrations & optimizations... My ICQ: 27429884 | Email: ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
sorry im still a bit confused, tried this with no luck =
<?php $x = str_replace(array("\r\n","\r"),"",$x); $x = strip_tags($hi->hello); print $x ?> |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Industry Role:
Join Date: Jul 2012
Posts: 3,073
|
Are you just wanting to populate a variable and echo to the screen?
<?php $x = "hello"; echo $x ?>
__________________
Live Sex Shows |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
No i am trying to echo $hi->hello on one line
$hi->hello = "hello how are you |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
So Fucking Fossilized
Industry Role:
Join Date: Sep 2011
Posts: 1,432
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 | |
So Fucking Banned
Industry Role:
Join Date: Sep 2010
Posts: 3,405
|
Quote:
Code:
<?php $hi->hello = "hello how are you"; $one_line = trim(preg_replace('/\s+/', ' ', $hi->hello)); print $one_line; ?> |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 |
(>^_^)b
Industry Role:
Join Date: Dec 2011
Posts: 7,223
|
Would PHP trim work?
echo trim($hi,"/n");
__________________
![]() I've referred over $1.7mil in spending this past year, you should join in. ![]() ![]() I make a lot more money in the medical field in a lab now, fuck you guys. Don't ask me to come back, but do join Chaturbate in my sig, it still makes bank without me touching shit for years.. ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,078
|
never mind... Next time I will read the thread first ;p
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 |
So Fucking Banned
Industry Role:
Join Date: Sep 2010
Posts: 3,405
|
Trim is for stripping at the beginning and end of a string.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 | |
(>^_^)b
Industry Role:
Join Date: Dec 2011
Posts: 7,223
|
Quote:
![]()
__________________
![]() I've referred over $1.7mil in spending this past year, you should join in. ![]() ![]() I make a lot more money in the medical field in a lab now, fuck you guys. Don't ask me to come back, but do join Chaturbate in my sig, it still makes bank without me touching shit for years.. ![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#14 | |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,078
|
Quote:
If he needs to get rid of a <br> then strip_tags does that or you could include it in a replace. If he needs to get rid of a carriage return/linefeed then the replace can do that. Since we don't know exactly which needs to be done then a solution like dankasaur's that covers both possibilities will work. A one line solution would be like <?php print str_replace(array("\r\n","\r","<br>")," ",$hi->hello); ?> .
__________________
All cookies cleared! |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#15 |
So Fucking Banned
Industry Role:
Join Date: Sep 2010
Posts: 3,405
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#16 | |
So Fucking Fossilized
Industry Role:
Join Date: Sep 2011
Posts: 1,432
|
Quote:
![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#17 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,078
|
Just an add on.
I was assuming that it was a <br> in there. It could be all sorts of html code that is invisble to the eye (hidden divs, etc) so probably to make sure all possible tags are covered then a better one line solution might be <?php print strip_tags(str_replace(array("\r\n","\r")," ",$hi->hello)); ?> And I tend not to use \r\n so my way would probably be (actually my way would be to change it in the db but the OP says he does not have that access, so) <?php print strip_tags(str_replace(array(chr(10),chr(13))," ",$hi->hello)); ?> which is basically the same thing just different. The OP needs to look under the sheets (view source) and see exactly what is in the output that is causing the line break in order to derive the best solution. .
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#18 |
<&(©¿©)&>
Industry Role:
Join Date: Jul 2002
Location: Chicago
Posts: 47,882
|
mkx,
just hit me up on icq: 33375924 and I'll hook you up... before one line of code question turns into a 3 page thread... ![]()
__________________
Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000 Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager ![]() Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#19 | |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,078
|
Quote:
.
__________________
All cookies cleared! |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#20 |
So Fucking Fossilized
Industry Role:
Join Date: Sep 2011
Posts: 1,432
|
Not to mention that if he goes off privately with you instead of collectively being helped, what if someone else runs into this problem? Nothing like finding a similar problem thread and then being disappointed because nobody posted the fix.
|
![]() |
![]() ![]() ![]() ![]() ![]() |