Jump to content

while - line by line decipher


esostigma

Recommended Posts

need some expert help below.  i need someone that knows to break down what is going on here line by line.  all help much appreciated.  thanks to everyone in advance.  :-)

 

while ($row = getrow($result))
{
	$highest = 0;
	foreach ($row as $value)
	{
		$value = trim($value);
		$transnum = substr($value, (strlen($value) - 5));
		if( $highest < $transnum ) $highest = $transnum;
	}
}

Link to comment
https://forums.phpfreaks.com/topic/52566-while-line-by-line-decipher/
Share on other sites

// While $row can be set by getrow($result) // which probably returns an array of a query; loop.
while ($row = getrow($result))
{
	$highest = 0; // set the highest to be 0
                         // foreach item in row set it to be $value
	foreach ($row as $value)
	{
                                      // make $value = the trimmed version of itself www.php.net/trim
		$value = trim($value);
                                      // make $transnum = the substring of $value of it's length minus 5  www.php.net/substr  www.php.net/strlen
		$transnum = substr($value, (strlen($value) - 5));
                                      // if the highest is less than the transnum than set the highest equal to transnum.
		if( $highest < $transnum ) $highest = $transnum;
	}
}

 

This code is flawed though. The $highest = 0 needs to be set outside the while statement as after each run it gets reset to 0.

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.