I am really really bad at regular expression, I don’t know why but I can never really figure it out.
at the moment I use the following code to put an image in front of my first navigation item:
$nav_out = preg_replace('/<a([^>]*)>/', '<a$1><img src="http://myimage.gif" border="0" />', wp_nav_menu( array('theme_location' => 'menu-1', 'echo' => 0, 'container' => false )),1);
echo $nav_out;
However I need the image to be at the BACK of my first item. I tried a bunch of things but I just can’t get it to work 🙁
Can anybody help me out here?
Would be really really gratefull!
EDIT: I took some screenshots
my original one with the image at the front
$nav_out = preg_replace('/<a([^>]*)>/', '<a$1><img src="http://www.bimiii.com/myimg.gif" border="0" />',

the suggestion made by marcio
$nav_out = preg_replace('/<a([^>]*)>/', '<img src="http://www.bimiii.com/myimg.gif" border="0" /><a$1>',

and I know this one is wrong but I just wanted to show it anyway
$nav_out = preg_replace('</a>', '</a><img src="http://www.bimiii.com/myimg.gif" border="0" />',

The regex in this case is used to match any anchor tag and inject the image near the anchors in your menu. You can reposition the image just using CSS:
Hope that helps.