Jump to content

[SOLVED] arrays


gazever

Recommended Posts

Hi I was given this code yesterday by effigy,

 

<pre>
<?php
$data = '8,6,9,2,,,7,4,5,3,,,2,1,5,3,4,,,6,9,4,5,3,6,9,8';
$data = str_replace(',,', ', ,', $data);
$array = explode(',', $data);
print_r($array);
?>
</pre>

 

However this string opens from a txt file and replaces the ,, with a space character, I loop through this a few times, incase there are two empty values in a row, producing ,,,     

 

However how would I loop thorugh the array and replace all values that are "" empty to the   value, as if the first value of the array is empty It will not change to a space?

 

I'm sure this is really simple to do.

 

Thanks

 

Gaz

Link to comment
https://forums.phpfreaks.com/topic/39620-solved-arrays/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.