Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
strpos() doesn't work for text with <br>
Old 07-03-2008, 10:12 AM strpos() doesn't work for text with <br>
drew22299's Avatar
Skilled Talker

Posts: 93
Trades: 0
Hi,

I have a textarea that users enter data into and another form on a different page that gets the data the user previously entered and displays only the first 48 characters using strpos()

This works ok, but it doesn't work when the user has pressed enter when typing - here is the code I am using:

PHP Code:
$notes=$getEventId['notes']." ";
 
            
$chars 48;
            
$notes $notes." ";
            
$notes substr($notes,0,$chars);
            
$notes substr($notes,0,strrpos($notes,' '));
            
$notes $notes."..."
How can the above code be modified to work when the user has pressed the enter key?

Thanks,
drew22299 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-03-2008, 08:07 PM Re: strpos() doesn't work for text with <br>
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
PHP Code:
$notes $getEventId['notes'] . ' ';
$notes str_replace("\r"' '$notes);
$notes str_replace("\n"' '$notes);
while (
strstr($notes'  ')) $notes str_replace('  '' '$notes);
 
$chars 48;
$notes $notes." ";
$notes substr($notes,0,$chars);
$notes substr($notes,0,$chars);
$notes substr($notes,0,strrpos($notes,' '));
$notes $notes."..."
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 07-07-2008, 06:07 AM Re: strpos() doesn't work for text with <br>
drew22299's Avatar
Skilled Talker

Posts: 93
Trades: 0
Thanks for adding the extra code mgraphic

Last edited by drew22299; 07-07-2008 at 06:09 AM..
drew22299 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to strpos() doesn't work for text with <br>
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.43799 seconds with 12 queries