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
website
How do I register Exchange 2010 with Windows Server Backup on Windows Server 2008 R2
Exchange 2003 - new Server - still routing through old smtp virtual server
get latest file in the directory in unix
calling C++ dll function from c#
ical not syncing with exchange 2010 - snow leopard
After Effect
make a gigabit rj45 loopback plug
Customizing Drupal theme - Reload not updated
Check entries from user with Javascript