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 Link to comment https://forums.phpfreaks.com/topic/23070-simple-regex/ 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] Link to comment https://forums.phpfreaks.com/topic/23070-simple-regex/#findComment-104273 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.