RE: [PHP] simple question...

2001-09-20 Thread Eric O'Connell


 One more thing... If I got '2001-09-01'
 Is there a fast way of incrementing the month of it?
 making it '2001-10-01' ?

list($year, $month, $day) = explode(-, $date);
$month++;
if ($month == 13)
$month = 1;
$date = $year-$month-$day;

Eric O'Connel

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Weird results from Left Shift

2001-09-19 Thread Eric O'Connell

 Okay, from the manual I have
 $a  $b - Shift the bits of $a $b steps to the left
 
 When I run the code
 
 ?php
 $num = 0001000;
 echo Number is $numBR;
 $num = $num  1;
 echo Shifted Number is $num;
 ?
 
 I get the output
 
 Number is 0001000
 Shifted Number is 2000
 
 What am I missing?!?

$num = 0001000; sets $num to be 1000, not 0001000 binary.

As I'm not sure if PHP has a binary type, you can use hex:

?php

$num = 0x8;   // 0001000 binary
echo Number is $numBR;
$num = $num  1;
echo Shifted Number is $num;

?

Eric O'Connell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]