3s2ng Posted October 5, 2006 Share Posted October 5, 2006 Hello Freaks,I have an array which contains names,example: $name = array("Mark", "Mark & Lester", "Yoy & Me");What I want is to change Mark & Lester to Mark_Lester.I hope you can help me.ThanksMARK Quote Link to comment Share on other sites More sharing options...
effigy Posted October 5, 2006 Share Posted October 5, 2006 [code]<pre><?php $names = array( 'Mark', 'Mark & Lester', 'Yoy & Me' ); foreach ($names as &$name) { $name = preg_replace('/\s+&\s+/', '_', $name); } print_r($names); ?></pre>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.