-
str_replace puzzle
PHP Code:
<?php
$lastUpdate = date( 'j F Y', filemtime( 'pageContent/reviewActivity.txt' ) );
$bigCount = 0;
echo "<br /><br />";
$bigData = file_get_contents ("bigCollection");
echo $bigData;
echo "<br />Kilroy knocked!<br /><br />";
echo str_replace (" ", "", $bigData);
str_replace (" ", "", $bigData);
$lineItem = explode ("*", $bigData);
echo "<br />Kilroy entered!<br /><br />";
foreach ($lineItem as $item) {
echo "Item = " . $item . "<br />";
}
echo "<br />Kilroy left!";
?>
<br />
<br />
<a href="http://www.marainlaw.com/bottomline.php"><img border="2" src="images/marain-logo.gif" alt="***************" width="130" height="75" class="right" /></a>
<br />
<br />
$bigData contains several sets of six two-digit numbers separated by spaces. Where that happens, I'm trying to use the str_replace function to convert them to a single twelve-digit number. When I echo the str_replace operation, all works as intended. But then when I attempt to actually do the replacement and explode the string, the original sequence is unchanged.
The page in question is https://www.marainlaw.com/page.php?here=reviewActivity
-
I have not looked too closely, but I notice that this one line does not do anything:
Code:
str_replace (" ", "", $bigData);
It should be something like:
Code:
$bigData = str_replace (" ", "", $bigData);
It would help to know what the results are that you are getting as opposed to what you are expecting as well as what what the contents of $bigData is/are.
-
James,
You hit the nail on its proverbial head. Thank you!
Given your observation, I can now fix it easily. [URL]https://www.marainlaw.com/page.php?here=reviewActivity] shows the contents of $bigData, what I was expecting, and what I got. Well, when I make the correction you suggest, it will no longer show what I got.