Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.