• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 343
  • Last Modified:

Replace a match opccurance in a string only once vith php4

hi i have the following:
$replaceing = array("<td bordercolor=\"#000000\">$pname</td>");
$replaceing2 = array("<td bordercolor=\"#000000\"colspan=\"$count\" ><div align=\"center\">$pname</div></td>");
$table = str_replace($replaceing, $replaceing2, $table);

which replaces all found instances in $table but i need to only replace the first instance but i am stuck on php4
please help
0
greenbug2002
Asked:
greenbug2002
1 Solution
 
evguenCommented:
0
 
dr_dedoCommented:
try this
function xReplace ($arr1,$arr2,$subject){
	list ($k1,$value1) =$arr1;
	list ($k2,$value2) =$arr2;
	return str_replace($value1, $value2, $subject);
}
$table = xReplace($replaceing,$replaceing2,$table);

Open in new window

0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now