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
lpr print server issue
Exchange 2010 Tarpit issue
better processer?
Setting up exchange
i need a regexp which eliminate all what's not a number or a ";"
DOS Batch Turnkey system for Win95
Setup/Configure Outlook settings using group policy
How to change Hotsname and ipaddress of Oracle Databse server
Windows Server 2008 - RAID storage > 2 Tb
How to disable form fields in Coldfusion flash form by clicking a checkbox?