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
checking login & pass with curl
Should Sys Admins (Domain Admins) also have user accounts?
Outlook 2007 Tasks sending out automatic status reports (updates) when attachments are opened
How can I prevent a user to install software on a Windows XP computer
Exchange 2010 & GroupWIse 7
Find Label in Datalist within Gridview
Windows Update on ISA 2006 Server
MS Dynamics GP 10 Security query
HP-UNIX - compressing/zipping files that are 31GB
How to setup zywall 10w firewall gateway