esostigma Posted May 22, 2007 Share Posted May 22, 2007 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; } } Quote Link to comment https://forums.phpfreaks.com/topic/52566-while-line-by-line-decipher/ Share on other sites More sharing options...
per1os Posted May 22, 2007 Share Posted May 22, 2007 // 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. Quote Link to comment https://forums.phpfreaks.com/topic/52566-while-line-by-line-decipher/#findComment-259358 Share on other sites More sharing options...
esostigma Posted May 22, 2007 Author Share Posted May 22, 2007 can you elaborate on the rest of what is going on here? ty! Quote Link to comment https://forums.phpfreaks.com/topic/52566-while-line-by-line-decipher/#findComment-259360 Share on other sites More sharing options...
Barand Posted May 23, 2007 Share Posted May 23, 2007 That's exactly what he has done, and given you links to the php manual for the functions used eg www.php.net/trim Use them. Quote Link to comment https://forums.phpfreaks.com/topic/52566-while-line-by-line-decipher/#findComment-259462 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.