So here is my code. I have to replace a space with an asterisk and if there are an occurence of two spaces in a row in the string replace it with one dash
<?php
$string = "Keep your spacing perfect!";
$search = array(' ',' ');
$search2 = array('*','-');
echo str_replace($search, $search2, $string);
?>
when i run it it prints out
Keep*your****spacing***perfect!
which is suppose to be
Keep*your--spacing-*perfect!
so what is wrong with my code and how do i fix it? I did some research but could not come to a solution. Any help is appreciated!