I'm sure it was a typo using $valor in the example when the array is $array, so I'll move on 🙂
You need to wrap the value with single quotes:
echo("<input type='text' name=text1 size=15 maxlength=15 value='".$valor."'>");
instead of:
echo("<input type='text' name=text1 size=15 maxlength=15 value=".$valor.">");
It's a subtle change, but very necessary. In your example, the 2nd word ("town") is not included in the value, but as a parameter to "input".
Hope this helps.
-Rich