Microsoft
Software
Hardware
Network
Question : PHP: Find and Replace only 1st occurance
I want PHP to go through my string and only replace the first occurrence of the words I want replaced. str_replace seems to replace every occurrence, I just want to have the 1st occurrence replaced. How can I go about doing this?
Answer : PHP: Find and Replace only 1st occurance
Use preg_replace ...here is an example..
<?
$var = 'abcdef abcdef abcdef';
// pattern, replacement, string, limit
echo preg_replace('/abc/', '123', $var, 1); // outputs '123def abcdef abcdef'
?>
Random Solutions
How can you search e-mail within Outlook 2010 and not use the index?
Setup multiple ethernet interfaces on Redhat to support Oracle RAC
Adding Outlook Calendar entries from server
Repeating SQL
Online Forms and SQL
ipod opener
Unable to deploy a clickonce application on some clients!
Temporary Mailbox
.NET Trust Issue
How do I transfer an existing Clipper data base running in dos on a XP PC?