[PHP] Convert excel time to date time

2010-07-17 Thread Mohd Shakir bin Zakaria
Hi,

I've been trying to convert this excel date to the date time format,
but only managed to get it up to the seconds;

The following code;

#
$data=39604.62164;
date("Y-m-d",mktime(0,0,0,1,$data-1,1900));
#

will give this output
2008-06-05

changing it to


date("H-i-s",mktime(0,0,0,1,$data-1,1900));


will only give
00-00-00

The output I'm looking for is like this one;
2008-06-05 14:55:09

Any idea?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Convert excel time to date time

2010-07-17 Thread Ashley Sheridan
On Sat, 2010-07-17 at 19:47 +0800, Mohd Shakir bin Zakaria wrote:

> Hi,
> 
> I've been trying to convert this excel date to the date time format,
> but only managed to get it up to the seconds;
> 
> The following code;
> 
> #
> $data=39604.62164;
> date("Y-m-d",mktime(0,0,0,1,$data-1,1900));
> #
> 
> will give this output
> 2008-06-05
> 
> changing it to
> 
> 
> date("H-i-s",mktime(0,0,0,1,$data-1,1900));
> 
> 
> will only give
> 00-00-00
> 
> The output I'm looking for is like this one;
> 2008-06-05 14:55:09
> 
> Any idea?
> 


Of course it will, because you're only passing 0 values for the hours,
minutes and seconds. I'm not quite sure what the number 39604.62164
represents, or why it is coming up with a value like that when you're
passing the number in as the day argument to the date() call, but I
assume it allows for a fallover of the date value.

Look at the mktime() function on the man page and you'll see the correct
usage of it.

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] Converting a javascript calculating page to a PHP one

2010-07-17 Thread The Doctor

Quick question, ho easy is this?

-- 
Member - Liberal International  This is doc...@nl2k.ab.ca Ici doc...@nl2k.ab.ca
God, Queen and country! Never Satan President Republic! Beware AntiChrist 
rising! 
http://twitter.com/rootnl2k http://www.facebook.com/dyadallee
Australia!! Vote to throw the REpublicans to the sharks!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Converting a javascript calculating page to a PHP one

2010-07-17 Thread shiplu
You can use SpiderMoneky of Mozilla or V8 of Google to execute the js.
Later you can also create a php extension to call your lib.
The flow will be like this,

PHP <--> PHP_V8_WRAPPER <--> V8 <--> EXECUTE_JS


Shiplu Mokadd.im
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Converting a javascript calculating page to a PHP one

2010-07-17 Thread Ashley Sheridan
On Sat, 2010-07-17 at 09:35 -0600, The Doctor wrote:

> Quick question, ho easy is this?
> 
> -- 
> Member - Liberal InternationalThis is doc...@nl2k.ab.ca Ici 
> doc...@nl2k.ab.ca
> God, Queen and country! Never Satan President Republic! Beware AntiChrist 
> rising! 
> http://twitter.com/rootnl2k http://www.facebook.com/dyadallee
> Australia!! Vote to throw the REpublicans to the sharks!
> 


Not sure exactly what you're after, but PHP and Javascript don't run in
the same place (PHP is all on the server and is never seen by the
browser) so some things just won't translate.

Having said that, PHP is far more powerful, and anything Javascript can
do calculation-wise, PHP can do faster.

So to answer your question, some things like only updating part of the
page won't be possible without Javascript, but on the whole you should
be able to work round that. As for how easy it is, well, as you've not
said what it is you want to convert, there's no way to tell how easy it
would be.

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] PHP Pill

2010-07-17 Thread Rick Dwyer

Hello all.

I inquired about the problem below on a FM board but no one could  
help.  Hoping someone here may have an explanation or a workaround.


I have PHP Pill installed on both a Mac and PC versions of FileMaker  
11. On the Mac, things behave as expected. On the PC, they do not. My  
code is below:


$old_string= 'Antique Houses™ Appointment Calendar';
$find = '/[^a-z0-9]/i';
$replace = '';
$new_string = preg_replace($find, $replace, $old_string);
$new_string = trim($new_string, "");
echo $new_string;

So on the Mac, the above returns:
AntiqueHousesAppointmentCalendar

vs. the PC returns:
AntiqueHousesTAppointmentCalendar

Is there any reason the PC version of FM converts the TM symbol to a T  
instead of removing as it should via regex?

Thanks.


--Rick



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Pill

2010-07-17 Thread Ashley Sheridan
On Sat, 2010-07-17 at 12:30 -0400, Rick Dwyer wrote:

> Hello all.
> 
> I inquired about the problem below on a FM board but no one could  
> help.  Hoping someone here may have an explanation or a workaround.
> 
> I have PHP Pill installed on both a Mac and PC versions of FileMaker  
> 11. On the Mac, things behave as expected. On the PC, they do not. My  
> code is below:
> 
> $old_string= 'Antique Houses™ Appointment Calendar';
> $find = '/[^a-z0-9]/i';
> $replace = '';
> $new_string = preg_replace($find, $replace, $old_string);
> $new_string = trim($new_string, "");
> echo $new_string;
> 
> So on the Mac, the above returns:
> AntiqueHousesAppointmentCalendar
> 
> vs. the PC returns:
> AntiqueHousesTAppointmentCalendar
> 
> Is there any reason the PC version of FM converts the TM symbol to a T  
> instead of removing as it should via regex?
> Thanks.
> 
> 
> --Rick
> 
> 
> 


It sounds like somewhere along the line the character format isn't being
observed. I'm not sure what PHP Pill is, and a quick Google for it
brought up some odd results which didn't look like software! What
happens when you output the string length on each system? I'm assuming
you're using Windows on the PC, and not Linux, as that is where I've
seen most issues with character encoding in the past.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] PHP Pill

2010-07-17 Thread Rick Dwyer

Hi Ash.

Yes, windows XP, I believe.  PHP Pill is a FileMaker plugin that  
allows you to execute PHP from within your FM code.  What I don't  
understand is that the PHP regex should be removing ALL items not in  
my regex list... it does so in FM on the Mac but not on the PC.  But  
the plugin is working as it is removing everthing... but gets tripped  
on the trade mark symbol.  I sent a side by side screen shot of the  
fields on the mac and pc to your personal address.




 --Rick


On Jul 17, 2010, at 12:34 PM, Ashley Sheridan wrote:


On Sat, 2010-07-17 at 12:30 -0400, Rick Dwyer wrote:


Hello all.

I inquired about the problem below on a FM board but no one could
help.  Hoping someone here may have an explanation or a workaround.

I have PHP Pill installed on both a Mac and PC versions of FileMaker
11. On the Mac, things behave as expected. On the PC, they do not. My
code is below:

$old_string= 'Antique Houses™ Appointment Calendar';
$find = '/[^a-z0-9]/i';
$replace = '';
$new_string = preg_replace($find, $replace, $old_string);
$new_string = trim($new_string, "");
echo $new_string;

So on the Mac, the above returns:
AntiqueHousesAppointmentCalendar

vs. the PC returns:
AntiqueHousesTAppointmentCalendar

Is there any reason the PC version of FM converts the TM symbol to  
a T

instead of removing as it should via regex?
Thanks.


--Rick





It sounds like somewhere along the line the character format isn't  
being observed. I'm not sure what PHP Pill is, and a quick Google  
for it brought up some odd results which didn't look like software!  
What happens when you output the string length on each system? I'm  
assuming you're using Windows on the PC, and not Linux, as that is  
where I've seen most issues with character encoding in the past.


Thanks,
Ash
http://www.ashleysheridan.co.uk






Re: [PHP] PHP Pill

2010-07-17 Thread Ashley Sheridan
On Sat, 2010-07-17 at 13:27 -0400, Rick Dwyer wrote:

> Hi Ash.
> 
> 
> 
> Yes, windows XP, I believe.  PHP Pill is a FileMaker plugin that
> allows you to execute PHP from within your FM code.  What I don't
> understand is that the PHP regex should be removing ALL items not in
> my regex list... it does so in FM on the Mac but not on the PC.  But
> the plugin is working as it is removing everthing... but gets tripped
> on the trade mark symbol.  I sent a side by side screen shot of the
> fields on the mac and pc to your personal address.
> 
> 
> 
> 
>  
>  --Rick
> 
> 
> 
> 
> 
> 
> On Jul 17, 2010, at 12:34 PM, Ashley Sheridan wrote:
> 
> 
> 
> > On Sat, 2010-07-17 at 12:30 -0400, Rick Dwyer wrote: 
> > 
> > > Hello all.
> > > 
> > > I inquired about the problem below on a FM board but no one could  
> > > help.  Hoping someone here may have an explanation or a workaround.
> > > 
> > > I have PHP Pill installed on both a Mac and PC versions of FileMaker  
> > > 11. On the Mac, things behave as expected. On the PC, they do not. My  
> > > code is below:
> > > 
> > > $old_string= 'Antique Houses™ Appointment Calendar';
> > > $find = '/[^a-z0-9]/i';
> > > $replace = '';
> > > $new_string = preg_replace($find, $replace, $old_string);
> > > $new_string = trim($new_string, "");
> > > echo $new_string;
> > > 
> > > So on the Mac, the above returns:
> > > AntiqueHousesAppointmentCalendar
> > > 
> > > vs. the PC returns:
> > > AntiqueHousesTAppointmentCalendar
> > > 
> > > Is there any reason the PC version of FM converts the TM symbol to a T  
> > > instead of removing as it should via regex?
> > > Thanks.
> > > 
> > > 
> > > --Rick
> > > 
> > > 
> > > 
> > 
> > 
> > It sounds like somewhere along the line the character format isn't
> > being observed. I'm not sure what PHP Pill is, and a quick Google
> > for it brought up some odd results which didn't look like software!
> > What happens when you output the string length on each system? I'm
> > assuming you're using Windows on the PC, and not Linux, as that is
> > where I've seen most issues with character encoding in the past.
> > 
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> > 
> > 
> > 
> 
> 
> 

Well, I did suggest one thing that could be happening. What do both
string lengths come to?

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] PHP Pill

2010-07-17 Thread Rick Dwyer



On Jul 17, 2010, at 1:29 PM, Ashley Sheridan wrote:





Well, I did suggest one thing that could be happening. What do both
string lengths come to?



On the PC, the length of variable old string is 44 and new string is 39
On the Mac, the length of varialbe old string is 44 and new string is  
38.


This is all happening inside of FileMaker... I will test the PHP code  
inside a web browser on both plaforms to see what happens.


--Rick








Re: [PHP] PHP Pill

2010-07-17 Thread Rick Dwyer


On Jul 17, 2010, at 2:08 PM, Rick Dwyer wrote:




On Jul 17, 2010, at 1:29 PM, Ashley Sheridan wrote:





Well, I did suggest one thing that could be happening. What do both
string lengths come to?



On the PC, the length of variable old string is 44 and new string is  
39
On the Mac, the length of varialbe old string is 44 and new string  
is 38.


This is all happening inside of FileMaker... I will test the PHP  
code inside a web browser on both plaforms to see what happens.




OK to further bolster my assumption that this is a Scodigo/FM issue,  
the PHP code outputs identical string lengths to web browsers on both  
Mac and PC and both output the string correctly.

Only in FM on the PC does this occur.

 sure wish Scodigo would reply

--Rick

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Pill

2010-07-17 Thread Peter Lind
On 17 July 2010 20:08, Rick Dwyer  wrote:
>
>
> On Jul 17, 2010, at 1:29 PM, Ashley Sheridan wrote:
>>>
>>>
>>
>> Well, I did suggest one thing that could be happening. What do both
>> string lengths come to?
>
>
> On the PC, the length of variable old string is 44 and new string is 39
> On the Mac, the length of varialbe old string is 44 and new string is 38.
>
> This is all happening inside of FileMaker... I will test the PHP code inside
> a web browser on both plaforms to see what happens.
>
> --Rick
>

Windows uses two characters for newlines, mac uses one. Just a guess.

Regards
Peter

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Pill

2010-07-17 Thread Rick Dwyer


On Jul 17, 2010, at 2:34 PM, Peter Lind wrote:


On 17 July 2010 20:08, Rick Dwyer  wrote:



On Jul 17, 2010, at 1:29 PM, Ashley Sheridan wrote:





Well, I did suggest one thing that could be happening. What do both
string lengths come to?



On the PC, the length of variable old string is 44 and new string  
is 39
On the Mac, the length of varialbe old string is 44 and new string  
is 38.


This is all happening inside of FileMaker... I will test the PHP  
code inside

a web browser on both plaforms to see what happens.

--Rick



Windows uses two characters for newlines, mac uses one. Just a guess.

Regards
Peter

Thanks Peter, but while this may explain the character length  
difference, it doesn't explain the Trademark symbol.  I really  
beginning to believe that Scodigo, the manufacturer of PHP Pill is  
going to have to resolve this one.


--Rick


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Determining the similarity between a user supplied short piece of text (between 5 and 15 characters) and a list of similar length text items.

2010-07-17 Thread tedd

At 12:09 PM -0400 7/15/10, Daniel P. Brown wrote:

On Thu, Jul 15, 2010 at 11:54, Richard Quadling  wrote:


 I'm looking for is a way to compare what they've entered against a
 known list and to provide my 10 best guesses.


Look into the following functions and families:

levenshtein()
similar_text()


What would one use to have MySQL do the heavy lifting here?

In other words, are there similar MySQL functions?

Cheers,

tedd

PS: I thought of this Friday, but finally got my fingers to work today.

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Determining the similarity between a user supplied short piece of text (between 5 and 15 characters) and a list of similar length text items.

2010-07-17 Thread shiplu
There is an algorithm called longest common sub sequence.
If you can find the longest common sub sequence of the strings of
database for the given string and sort it, you'll get the most matched
word.
But I think this algo is developed already and available in your
context. It's name can be different.
As a developer I am not sure actually what function in php or mysql
serves the purpose.

Shiplu Mokadd.im
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] recursive

2010-07-17 Thread shahrzad khorrami
hi all :)
here is a xml file:


   
  
   
   
  
   



   
  
   
   
  
   

.
.
.
.
I have a xml file with a name for example(test.xml)..
and 3 tables of database, (group,directives,rules)
group is for recording the name of the opened xml file,  directives is for
storing the attributes of directive tag and rules is for 'rule' tag's
attributes.

I know I must use of recursive function.. but how? first read name of the
xml file and store it in group table, then the content of the file and fill
the directive and rules table...



   
  
   
   
  
   



how to implement it in php?

Thanks,
Shahrzad