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
Creating a new Array and Logical Drive
Is there a way to format an external drive so Linux and Windwos 7 can see it?
Citrix XenApp 5 Installation General Question
how do I conditionally format number in query result to show red if negative
In between Asterisk BLF
Exclamation Mark On Network Card After Virus Removal
assignment format.
How do I hide/show divs in a custom (ascx) control inside an asp:repeater control?
Register window DLL Remotely
dlookup with ' in the text does not work