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
Old 09-09-2007, 08:01 AM Is This Possible!
evans123's Avatar
Ultra Talker

Posts: 468
Trades: 0
Is it possible to find a letter on its own in a string for example

PHP Code:
$var "hello o hello o";
$str_replace str_replace("o","<b>o</b>",$text); 
but i only want to replace the o thats on its own and not in the hello?
evans123 is offline
Reply With Quote
View Public Profile Visit evans123's homepage!
 
 
Register now for full access!
Old 09-09-2007, 08:19 AM Re: Is This Possible!
purk's Avatar
Extreme Talker

Posts: 164
Name: James
Location: marbella & surrey
Trades: 0
if the 'o' is always preceeded by a space then use ' o'
__________________

Please login or register to view this content. Registration is FREE
- private villas direct from the owners - travel links always needed.
purk is offline
Reply With Quote
View Public Profile Visit purk's homepage!
 
Old 09-09-2007, 11:28 AM Re: Is This Possible!
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
yea, its quite simple you use:
PHP Code:
$var "hello o hello o";
$str_replace str_replace(" o ","<strong>o</strong>",$text); 
Lol that will only replace o's which have a space at the begining and end

btw <strong> is better than <b> aparently so its better to use it

same as <em> instead of <i>

Hope this helps

Talkupation Apprieciated
Dan
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-10-2007, 02:26 AM Re: Is This Possible!
Novice Talker

Posts: 13
Name: Ham
Location: Singapore
Trades: 0
or you could use preg_replace()
__________________
HAFIOŠ Networks -
Please login or register to view this content. Registration is FREE

Exclusive webhosting services
hafio is offline
Reply With Quote
View Public Profile Visit hafio's homepage!
 
Old 09-10-2007, 03:29 AM Re: Is This Possible!
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
If it is not the same character each time, you can use preg_replace as hafio says. Something like:

PHP Code:
$str preg_replace('#(\b)([\w]{1})(\b)#''$1<strong>$2</strong>$3'$str); 
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 09-10-2007, 05:31 AM Re: Is This Possible!
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Maybe some more details would help us give a more pesific response
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Reply     « Reply to Is This Possible!
 

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.44437 seconds with 12 queries