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
Changing Server Name with Exchange 2010 Installed
My Computer prints Very Tiny on Fresh Install
Access 2007 Update subform values with another subform
Union query
How can I compare Files in a Directory with a Text File List using a DOS Batch File?
Exchange 2010 Tarpit issue
quick question
Windows Server 2008 NLB Issue
How do I fix odbc call failed #1062 under access vba with a mysql backend?
IOS VPN Configuration for iPhone