Division Operator as Unsupported, WTF!?!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Division Operator as Unsupported, WTF!?!

Post by nigma »

Code: Select all

// Function to convert number to scientific notation and return as formatted string.
// Yes, I realize I could do the same with sprintf()
function toSci($n) {
  $power = 0;
  while ($n >= 10) {
    $n /= 10;
    $power++;
  }
  return ($power) ? $n.'e+'.$power : $n;
}
Lol, i'm getting a message that the division operator in this section of code is unsupported, WTF!?!
SBro
Forum Commoner
Posts: 98
Joined: Tue Sep 30, 2003 10:06 pm

Post by SBro »

Works fine for me when I tested? what's the exact error your getting, because i got no errors and an expected result.
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

I was using the function in the following context:

Code: Select all

list($somevar) = toSci(@mysql_fetch_array(@mysql_query("query")));
I was neglecting the fact that I was trying to make the assignment using the list function. Because my toSci function wasn't returning an array like list() expected I got the error. Anyway, problem solved, thanks for showing interest.
Post Reply