|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general-digest-help
lists.php.net
Date: Fri May 09 2008 - 16:44:54 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 9 May 2008 21:44:54 -0000 Issue 5450
Topics (messages 274056 through 274109):
Re: Get array as string --Help
274056 by: James Dempster
274058 by: Chetan Rane
274059 by: Chetan Rane
274060 by: Zoltán Németh
274064 by: Thiago Pojda
274065 by: Chetan Rane
british date format
274057 by: Merca, Ansta Ltd
274070 by: André Medeiros
274071 by: Shawn McKenzie
274072 by: André Medeiros
274075 by: Shawn McKenzie
274076 by: Shawn McKenzie
274078 by: André Medeiros
274092 by: Shawn McKenzie
Re: Odd performance problem
274061 by: Thiago Pojda
274069 by: Joeri Sebrechts
274073 by: Robert Cummings
Re: quick question
274062 by: Richard Heyes
274063 by: Thiago Pojda
274066 by: Richard Heyes
274067 by: Stut
Re: Where to start!
274068 by: David Giragosian
Re: Recursion... Sort of...
274074 by: Nathan Nobbe
274077 by: Matt Neimeyer
274087 by: tedd
php.ini
274079 by: Michael Satterwhite
274080 by: Thiago Pojda
274081 by: André Medeiros
274084 by: Wolf
274085 by: Adam Richardson
274093 by: Shawn McKenzie
274094 by: Michael Satterwhite
274095 by: Michael Satterwhite
274097 by: Nathan Nobbe
274099 by: Janet Valade
274109 by: Nathan Nobbe
Re: php.ini (typo in previous)
274082 by: Michael Satterwhite
Why doesn't working with array's ever stick in my thick head?
274083 by: Jason Pruim
274086 by: Dan Joseph
274088 by: tedd
274089 by: Jason Pruim
274090 by: Jason Pruim
274091 by: tedd
274101 by: Roberto Mansfield
274102 by: Roberto Mansfield
274103 by: Jason Pruim
Re: unsubscribe
274096 by: Wolf
274098 by: Jason Pruim
274107 by: tedd
xml processing cdata
274100 by: Chris W
usort inside a class
274104 by: It Maq
274105 by: Richard Heyes
274106 by: It Maq
Re: [PHP-WIN] Include Question!
274108 by: Stut
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
serialize
--
/James
On Fri, May 9, 2008 at 10:40 AM, Shelley <myphplist
gmail.com> wrote:
> Hi all,
>
> If I have an array like this:
> $arr = array (
> 'c' => 'd',
> 'e' => 'f');
>
> How can I convert this array into a string? I want to write an array into a
> file.
>
> Thanks in advance.
>
> --
> Regards,
> Shelley
>
attached mail follows:
What is the format you want it to be
You can use JSON_encode(array());
To get into a text like representation
Chetan Dattaram Rane
Software Engineer
-----Original Message-----
From: Shelley [mailto:myphplist
gmail.com]
Sent: Friday, May 09, 2008 3:11 PM
To: PHP General list
Subject: [PHP] Get array as string --Help
Hi all,
If I have an array like this:
$arr = array (
'c' => 'd',
'e' => 'f');
How can I convert this array into a string? I want to write an array into a
file.
Thanks in advance.
--
Regards,
Shelley
attached mail follows:
Yet another option is use serialize(array())
Chetan Dattaram Rane
Software Engineer
-----Original Message-----
From: Shelley [mailto:myphplist
gmail.com]
Sent: Friday, May 09, 2008 3:11 PM
To: PHP General list
Subject: [PHP] Get array as string --Help
Hi all,
If I have an array like this:
$arr = array (
'c' => 'd',
'e' => 'f');
How can I convert this array into a string? I want to write an array into a
file.
Thanks in advance.
--
Regards,
Shelley
attached mail follows:
> Yet another option is use serialize(array())
or you could use var_export if you need php code
http://php.net/var_export
greets,
Zoltán Németh
>
> Chetan Dattaram Rane
> Software Engineer
>
>
>
> -----Original Message-----
> From: Shelley [mailto:myphplist
gmail.com]
> Sent: Friday, May 09, 2008 3:11 PM
> To: PHP General list
> Subject: [PHP] Get array as string --Help
>
> Hi all,
>
> If I have an array like this:
> $arr = array (
> 'c' => 'd',
> 'e' => 'f');
>
> How can I convert this array into a string? I want to write an array into
> a
> file.
>
> Thanks in advance.
>
> --
> Regards,
> Shelley
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
Depending on your needs you could also use implode() and then save it to a
file.
Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
thiago.pojda
softpartech.com.br
Excelência em Softwares Financeiros
-----Mensagem original-----
De: Zoltán Németh [mailto:znemeth
alterationx.hu]
Enviada em: sexta-feira, 9 de maio de 2008 08:37
Para: Chetan Rane
Cc: 'Shelley'; 'PHP General list'
Assunto: RE: [PHP] Get array as string --Help
> Yet another option is use serialize(array())
or you could use var_export if you need php code
http://php.net/var_export
greets,
Zoltán Németh
>
> Chetan Dattaram Rane
> Software Engineer
>
>
>
> -----Original Message-----
> From: Shelley [mailto:myphplist
gmail.com]
> Sent: Friday, May 09, 2008 3:11 PM
> To: PHP General list
> Subject: [PHP] Get array as string --Help
>
> Hi all,
>
> If I have an array like this:
> $arr = array (
> 'c' => 'd',
> 'e' => 'f');
>
> How can I convert this array into a string? I want to write an array into
> a
> file.
>
> Thanks in advance.
>
> --
> Regards,
> Shelley
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
Yea but implde will loose the "Keys"
Chetan Dattaram Rane
Software Engineer
-----Original Message-----
From: Thiago Pojda [mailto:thiago.pojda
softpartech.com.br]
Sent: Friday, May 09, 2008 5:30 PM
To: 'Zoltán Németh'; 'Chetan Rane'
Cc: 'Shelley'; 'PHP General list'
Subject: RES: [PHP] Get array as string --Help
Depending on your needs you could also use implode() and then save it to a
file.
Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
thiago.pojda
softpartech.com.br
Excelência em Softwares Financeiros
-----Mensagem original-----
De: Zoltán Németh [mailto:znemeth
alterationx.hu]
Enviada em: sexta-feira, 9 de maio de 2008 08:37
Para: Chetan Rane
Cc: 'Shelley'; 'PHP General list'
Assunto: RE: [PHP] Get array as string --Help
> Yet another option is use serialize(array())
or you could use var_export if you need php code
http://php.net/var_export
greets,
Zoltán Németh
>
> Chetan Dattaram Rane
> Software Engineer
>
>
>
> -----Original Message-----
> From: Shelley [mailto:myphplist
gmail.com]
> Sent: Friday, May 09, 2008 3:11 PM
> To: PHP General list
> Subject: [PHP] Get array as string --Help
>
> Hi all,
>
> If I have an array like this:
> $arr = array (
> 'c' => 'd',
> 'e' => 'f');
>
> How can I convert this array into a string? I want to write an array into
> a
> file.
>
> Thanks in advance.
>
> --
> Regards,
> Shelley
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
Hi
Anyone "dd/mm/yyyy" as a date variable? strtotime - works fine with
"mm/dd/yyyy" but now with "dd/mm/yyyy". (PHP 4.x)
attached mail follows:
Try this:
http://pt.php.net/manual/en/function.strptime.php
Use the result with mktime to get the timestamp. I also checked
set_locale but that won't interfere with strtotime :(
On Fri, May 9, 2008 at 9:58 AM, Merca, Ansta Ltd <merca
ansta.co.uk> wrote:
> Hi
>
> Anyone "dd/mm/yyyy" as a date variable? strtotime - works fine with
> "mm/dd/yyyy" but now with "dd/mm/yyyy". (PHP 4.x)
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
Merca, Ansta Ltd wrote:
> Hi
>
> Anyone "dd/mm/yyyy" as a date variable? strtotime - works fine with
> "mm/dd/yyyy" but now with "dd/mm/yyyy". (PHP 4.x)
setlocale()
and then...
http://pt.php.net/manual/en/function.strftime.php
-Shawn
attached mail follows:
Shawn,
I think the idea here was to get a timestamp from a date in that
format he was telling about.
After replying however, I noticed that strptime is only implemented in
PHP5. Sorry about that mate.
On Fri, May 9, 2008 at 2:36 PM, Shawn McKenzie <nospam
mckenzies.net> wrote:
> Merca, Ansta Ltd wrote:
>>
>> Hi
>>
>> Anyone "dd/mm/yyyy" as a date variable? strtotime - works fine with
>> "mm/dd/yyyy" but now with "dd/mm/yyyy". (PHP 4.x)
>
> setlocale()
>
> and then...
>
> http://pt.php.net/manual/en/function.strftime.php
>
> -Shawn
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
André Medeiros wrote:
> Shawn,
>
> I think the idea here was to get a timestamp from a date in that
> format he was telling about.
>
> After replying however, I noticed that strptime is only implemented in
> PHP5. Sorry about that mate.
>
> On Fri, May 9, 2008 at 2:36 PM, Shawn McKenzie <nospam
mckenzies.net> wrote:
>> Merca, Ansta Ltd wrote:
>>> Hi
>>>
>>> Anyone "dd/mm/yyyy" as a date variable? strtotime - works fine with
>>> "mm/dd/yyyy" but now with "dd/mm/yyyy". (PHP 4.x)
>> setlocale()
>>
>> and then...
>>
>> http://pt.php.net/manual/en/function.strftime.php
>>
>> -Shawn
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
Couldn't see any other way. *nix strtotime is supposed to use locale.
$date = '20/12/1971';
$parts = explode('/', $date);
echo mktime(0 ,0, 0, $d[1], $d[0],$d[2])."\n";
-Shawn
attached mail follows:
Shawn McKenzie wrote:
> André Medeiros wrote:
>> Shawn,
>>
>> I think the idea here was to get a timestamp from a date in that
>> format he was telling about.
>>
>> After replying however, I noticed that strptime is only implemented in
>> PHP5. Sorry about that mate.
>>
>> On Fri, May 9, 2008 at 2:36 PM, Shawn McKenzie <nospam
mckenzies.net>
>> wrote:
>>> Merca, Ansta Ltd wrote:
>>>> Hi
>>>>
>>>> Anyone "dd/mm/yyyy" as a date variable? strtotime - works fine with
>>>> "mm/dd/yyyy" but now with "dd/mm/yyyy". (PHP 4.x)
>>> setlocale()
>>>
>>> and then...
>>>
>>> http://pt.php.net/manual/en/function.strftime.php
>>>
>>> -Shawn
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
> Couldn't see any other way. *nix strtotime is supposed to use locale.
>
Fixed that for me:
$date = '20/12/1971';
$d = explode('/', $date);
echo mktime(0 ,0, 0, $d[1], $d[0],$d[2])."\n";
>
> -Shawn
attached mail follows:
Yeah, that would be the way to do it ;)
On Fri, May 9, 2008 at 3:54 PM, Shawn McKenzie <nospam
mckenzies.net> wrote:
> Shawn McKenzie wrote:
>>
>> André Medeiros wrote:
>>>
>>> Shawn,
>>>
>>> I think the idea here was to get a timestamp from a date in that
>>> format he was telling about.
>>>
>>> After replying however, I noticed that strptime is only implemented in
>>> PHP5. Sorry about that mate.
>>>
>>> On Fri, May 9, 2008 at 2:36 PM, Shawn McKenzie <nospam
mckenzies.net>
>>> wrote:
>>>>
>>>> Merca, Ansta Ltd wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> Anyone "dd/mm/yyyy" as a date variable? strtotime - works fine with
>>>>> "mm/dd/yyyy" but now with "dd/mm/yyyy". (PHP 4.x)
>>>>
>>>> setlocale()
>>>>
>>>> and then...
>>>>
>>>> http://pt.php.net/manual/en/function.strftime.php
>>>>
>>>> -Shawn
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>> Couldn't see any other way. *nix strtotime is supposed to use locale.
>>
> Fixed that for me:
>
> $date = '20/12/1971';
> $d = explode('/', $date);
> echo mktime(0 ,0, 0, $d[1], $d[0],$d[2])."\n";
>
>>
>> -Shawn
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
André Medeiros wrote:
> Yeah, that would be the way to do it ;)
>
> On Fri, May 9, 2008 at 3:54 PM, Shawn McKenzie <nospam
mckenzies.net> wrote:
>> Shawn McKenzie wrote:
>>> André Medeiros wrote:
>>>> Shawn,
>>>>
>>>> I think the idea here was to get a timestamp from a date in that
>>>> format he was telling about.
>>>>
>>>> After replying however, I noticed that strptime is only implemented in
>>>> PHP5. Sorry about that mate.
>>>>
>>>> On Fri, May 9, 2008 at 2:36 PM, Shawn McKenzie <nospam
mckenzies.net>
>>>> wrote:
>>>>> Merca, Ansta Ltd wrote:
>>>>>> Hi
>>>>>>
>>>>>> Anyone "dd/mm/yyyy" as a date variable? strtotime - works fine with
>>>>>> "mm/dd/yyyy" but now with "dd/mm/yyyy". (PHP 4.x)
>>>>> setlocale()
>>>>>
>>>>> and then...
>>>>>
>>>>> http://pt.php.net/manual/en/function.strftime.php
>>>>>
>>>>> -Shawn
>>>>>
>>>>> --
>>>>> PHP General Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>
>>>>>
>>> Couldn't see any other way. *nix strtotime is supposed to use locale.
>>>
>> Fixed that for me:
>>
>> $date = '20/12/1971';
>> $d = explode('/', $date);
>> echo mktime(0 ,0, 0, $d[1], $d[0],$d[2])."\n";
>>
>>> -Shawn
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
I was bored. Just an example, and I named it _eur because I assume that
all European dates are this way, but some may have a / or a - or .
separator. intval() is to remove preceding 0 or it is treated as octal.
<?php
function strtotime_eur($date)
{
preg_match('|([0-9]{1,2})[/.-]([0-9]{1,2})[/.-]([0-9]{2,4})|',
$date, $parts);
if(count($parts) != 4) {
return false;
}
$d = intval($parts[1]);
$m = intval($parts[2]);
$y = intval($parts[3]);
return mktime(0 ,0, 0, $m, $d, $y);
}
?>
-Shawn
attached mail follows:
My tests on PHP 4.4.8
Default files:
Run 1)
done at 100045
Time: 12.5804 Seconds
Run 2)
done at 100045
Time: 12.6775 Seconds
Run 3)
done at 100045
Time: 13.0696 Seconds
Now editing the file, removed the switch case 'a' part.
Run 1)
done at 100045
Time: 12.6981 Seconds
Run 2)
done at 100045
Time: 12.8659 Seconds
Run 3)
done at 100045
Time: 12.7886 Seconds
As you can see, there's no really big difference here. It really does look
like it's slower, but .1 sec slower.
Hey Robert, this was just a semprom 3k... didn't know they were that dif
Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
thiago.pojda
softpartech.com.br
Excelência em Softwares Financeiros
-----Mensagem original-----
De: Robert Cummings [mailto:robert
interjinn.com]
Enviada em: sexta-feira, 9 de maio de 2008 04:44
Para: Joeri Sebrechts
Cc: php-general
lists.php.net
Assunto: Re: [PHP] Odd performance problem
On Wed, 2008-05-07 at 17:31 +0200, Joeri Sebrechts wrote:
> Hello,
>
> While debugging a script that ran too slowly I came across something that
I
> can't explain.
>
> It is inactive code that when removed doubles the run time of the script.
>
> Specifically, the issue is a switch statement, where one of the cases is
> never reached. If I remove the case from the code, the run time of the
> script goes from 6 seconds to 12 seconds.
>
> To see this problem in action, you can download the problematic script
here:
> http://sebrechts.net/files/2008/phpperfissue.zip
>
> Anyone have any ideas on how this is even possible? I'd like to improve
the
> run time of the script, but if every part of code that I take out makes it
> run longer ...
Runs the same for me either way... under PHP4 and PHP5. You must have a
nice system, takes 22 seconds both ways on my Athlon 2400 :)
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
Ha, I tried again today, and now there's no difference. I'm thinking now
that this was some sort of page boundary issue, or something of the sort. On
the one hand it's a relief I can move on, on the other hand it's frustrating
because I know for a fact that I saw those differences, and this problem
might be happening for some of our customers.
I'll just blame windows, that always works :)
By the way, a 22 second run-time is definitely abnormal. I only have a 3 ghz
P4, a 3 year old machine. When I disable xdebug it takes 4.5 seconds.
Another by the way, while measuring the performance of this script I noticed
that wincachegrind's time reports are incorrect. It reported a cumulative
run-time of about one second. Kcachegrind (the KDE4 for windows version) did
report correct times, so I'll be using that from now on.
""Thiago Pojda"" <thiago.pojda
softpartech.com.br> wrote in message
news:012501c8b1c9$bb172c20$0201a8c0
softpartech...
My tests on PHP 4.4.8
Default files:
Run 1)
done at 100045
Time: 12.5804 Seconds
Run 2)
done at 100045
Time: 12.6775 Seconds
Run 3)
done at 100045
Time: 13.0696 Seconds
Now editing the file, removed the switch case 'a' part.
Run 1)
done at 100045
Time: 12.6981 Seconds
Run 2)
done at 100045
Time: 12.8659 Seconds
Run 3)
done at 100045
Time: 12.7886 Seconds
As you can see, there's no really big difference here. It really does look
like it's slower, but .1 sec slower.
Hey Robert, this was just a semprom 3k... didn't know they were that dif
Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
thiago.pojda
softpartech.com.br
Excelência em Softwares Financeiros
-----Mensagem original-----
De: Robert Cummings [mailto:robert
interjinn.com]
Enviada em: sexta-feira, 9 de maio de 2008 04:44
Para: Joeri Sebrechts
Cc: php-general
lists.php.net
Assunto: Re: [PHP] Odd performance problem
On Wed, 2008-05-07 at 17:31 +0200, Joeri Sebrechts wrote:
> Hello,
>
> While debugging a script that ran too slowly I came across something that
I
> can't explain.
>
> It is inactive code that when removed doubles the run time of the script.
>
> Specifically, the issue is a switch statement, where one of the cases is
> never reached. If I remove the case from the code, the run time of the
> script goes from 6 seconds to 12 seconds.
>
> To see this problem in action, you can download the problematic script
here:
> http://sebrechts.net/files/2008/phpperfissue.zip
>
> Anyone have any ideas on how this is even possible? I'd like to improve
the
> run time of the script, but if every part of code that I take out makes it
> run longer ...
Runs the same for me either way... under PHP4 and PHP5. You must have a
nice system, takes 22 seconds both ways on my Athlon 2400 :)
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
On Fri, 2008-05-09 at 08:42 -0300, Thiago Pojda wrote:
>
> Runs the same for me either way... under PHP4 and PHP5. You must have
> a nice system, takes 22 seconds both ways on my Athlon 2400 :)
Maybe it's because I use Evolution for my mail client and it has
steadily increased it's CPU suckage over the years. I have no idea what
it does but these days I noticed it's eating a steady 8-12% of my
CPU :( Unfortunately I didn't like Thunderbird last time I checked.
Maybe I'll give Opera's mail client a go since I use the Opera browser
anyways.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
attached mail follows:
> Ho to read date from HTML form ->
> How to read $_POST['date']="dd/mm/YYYY" string variable as a date?
If you want a unix timestamp then try investigating strtotime().
--
Richard Heyes
+----------------------------------------+
| Access SSH with a Windows mapped drive |
| http://www.phpguru.org/sftpdrive |
+----------------------------------------+
attached mail follows:
What do you mean read a string as a date, a date object?
Atenciosamente,
www.softpartech.com.br
Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
thiago.pojda
softpartech.com.br
Excelência em Softwares Financeiros
-----Mensagem original-----
De: Merca, Ansta Ltd [mailto:merca
ansta.co.uk]
Enviada em: sexta-feira, 9 de maio de 2008 06:36
Para: php-general
lists.php.net
Assunto: [PHP] quick question
Hi
Ho to read date from HTML form ->
How to read $_POST['date']="dd/mm/YYYY" string variable as a date?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
> Well, when I try date('d/m/y', strtotime($_POST('date')) - it seems
> mixing day and month, I tried setlocale(LC_ALL, 'en_GB'); but it didn't
strtotime() returns a unix timestamp (ie number of seconds since
1970ish. Nothing to do with the date object.
--
Richard Heyes
+----------------------------------------+
| Access SSH with a Windows mapped drive |
| http://www.phpguru.org/sftpdrive |
+----------------------------------------+
attached mail follows:
>>
>> Well, when I try date('d/m/y', strtotime($_POST('date')) - it seems
>> mixing day and month, I tried setlocale(LC_ALL, 'en_GB'); but it
>> didn't
If you're sure that's the format of the date, this will do it...
list($day, $month, $year) = explode('/', $thedate);
$thetimestamp = mktime(0, 0, 0, $month, $day, $year);
-Stut
--
http://stut.net/
attached mail follows:
I doubt this will have any sway on the contributors to this thread,
but I ran across a db normalization "rule of thumb" yesterday in a
tutorial for another language: "Normalize until it hurts; De-normalize
until it works."
I lean towards finding a middle ground, so this makes sense to me.
--David.
attached mail follows:
On Fri, May 9, 2008 at 1:52 AM, Stut <stuttle
gmail.com> wrote:
> On 9 May 2008, at 02:02, Nathan Nobbe wrote:
>
>> function doStuff() {
>> static $callCount;
>>
>> if(!isset($callCount))
>> $callCount = 1;
>> else
>> $callCount++;
>>
>> /// do stuff w/ $callCount to potentially handle sub-tabs and stuff
>> if($callCount == 2) {
>> echo 'white on black';
>> } else {
>> echo 'black on white';
>> }
>> echo PHP_EOL;
>> }
>>
>
> No need for the first if, just give the static var a default value...
>
> function doStuff() {
> static $callCount = 0;
> $callCount++;
> ...
> }
>
> Much neater.
in my haste i had also thought that would set the value to 0 every time the
function was called, heh.
-nathan
attached mail follows:
Wow! Thanks guys! Here's what I ended up doing... To get...
Black on White - 1
White on Black - 2
Black on White - 3
Black on White - 3
White on Black - 2
Black on White - 3
I had to do something like...
function doStuff()
{
static $callCount = 0;
$callCount++;
if($callCount%2)
{ echo 'white on black - '.$callCount; }
else
{ echo 'black on white - '.$callCount; }
// Stuff that uses the depth count
$callCount--;
}
If I didn't put in the $callCount--; I ended up with something like this...
Black on White - 1
White on Black - 2
Black on White - 3
White on Black - 4
Black on White - 5
White on Black - 6
I saw where it was said that "oh he said it wasn't recursive"... Sorry
I wasn't clearer. In my mind a "true" recursive function is a function
that operates on it's own output like a factorial... Not just a
function that is called inside itself.
This got me where I needed to be and it is GREATLY appreciated!
Matt
attached mail follows:
At 5:48 PM -0400 5/8/08, Matt Neimeyer wrote:
>Is there a way to tell if a function has been called that has resulted
>in a call to the same function?
>
>We have an in-house CRM app that has a function that draws a tabbed
>panel on a screen... BUT if there are sub-sub-tabbed panels we want to
>invert the tab colors and panel colors...
>
>So...
>
>DrawSubTab($Set) - Black on White
> Content
> DrawSubTab($Set) - White on Black
> Content
> DrawSubTab($Set) - Black on White
> Content
> DrawSubTab($Set) - Black on White
> Content
> Etc...
>
>I suppose I could rewrite EVERY call to the function with a recursion
>count like DrawSubTab($Set,$DepthCount+1) but that would be a MASSIVE
>commit... whereas if the function can determine itself... All that
>said I can't think of a good way to do it without a bastardized global
>variable that track "how deep" we are and there is something that
>bothers me about that approach... Unless that really is the easiest
>way.
>
>Thanks in advance!
>
>Matt
If the CRM app uses a browser, then it sounds like a problem that
could be solved via css -- parent/child relationships.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
I'm trying to turn off magic quotes for a site. I've copied the php.ini
from /etc/php5/apache2 to the web site directory. In this file, I've changed
magic_quotes_gpc to read
magic_quotes.gpc = Off
When I run phpinfo() from this directory, it still shows magic quotes as being
on. I'm guessing there is another configuration parameter (either in the
Apache configuration or for php) that allows this to be processed. Would
someone be so kind as to help me here; I admit ignorance.
---Michael
attached mail follows:
phpinfo() should also tell you what php.ini is loaded.
Did you check that?
Atenciosamente,
www.softpartech.com.br
Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
thiago.pojda
softpartech.com.br
Excelência em Softwares Financeiros
-----Mensagem original-----
De: Michael Satterwhite [mailto:michael
weblore.com]
Enviada em: sexta-feira, 9 de maio de 2008 13:47
Para: php-general
lists.php.net
Assunto: [PHP] php.ini
I'm trying to turn off magic quotes for a site. I've copied the php.ini
from /etc/php5/apache2 to the web site directory. In this file, I've changed
magic_quotes_gpc to read
magic_quotes.gpc = Off
When I run phpinfo() from this directory, it still shows magic quotes as
being
on. I'm guessing there is another configuration parameter (either in the
Apache configuration or for php) that allows this to be processed. Would
someone be so kind as to help me here; I admit ignorance.
---Michael
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
I'm not sure PHP5 would read php.ini from that directory.
You should take in account that your hosting company may _NOT_ allow
you to change certain parameters. That said, try visiting
http://us2.php.net/configuration.changes and see how that works for
you.
Good luck
On Fri, May 9, 2008 at 4:47 PM, Michael Satterwhite <michael
weblore.com> wrote:
> I'm trying to turn off magic quotes for a site. I've copied the php.ini
> from /etc/php5/apache2 to the web site directory. In this file, I've changed
> magic_quotes_gpc to read
> magic_quotes.gpc = Off
>
> When I run phpinfo() from this directory, it still shows magic quotes as being
> on. I'm guessing there is another configuration parameter (either in the
> Apache configuration or for php) that allows this to be processed. Would
> someone be so kind as to help me here; I admit ignorance.
>
> ---Michael
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
---- Michael Satterwhite <michael
weblore.com> wrote:
> I'm trying to turn off magic quotes for a site. I've copied the php.ini
> from /etc/php5/apache2 to the web site directory. In this file, I've changed
> magic_quotes_gpc to read
> magic_quotes.gpc = Off
>
> When I run phpinfo() from this directory, it still shows magic quotes as being
> on. I'm guessing there is another configuration parameter (either in the
> Apache configuration or for php) that allows this to be processed. Would
> someone be so kind as to help me here; I admit ignorance.
>
> ---Michael
'
When making changes to Apache configuration read files, you have to RESTART APACHE before those changes take effect.
However you can use php's ini_set () function to set a number of settings on the fly that can be changed per page change.
HTH,
Wolf
attached mail follows:
And, at some hosts you have to change the settings in htaccess as opposed to
php.ini.
On Fri, May 9, 2008 at 12:53 PM, André Medeiros <andre.caum
gmail.com>
wrote:
> I'm not sure PHP5 would read php.ini from that directory.
>
> You should take in account that your hosting company may _NOT_ allow
> you to change certain parameters. That said, try visiting
> http://us2.php.net/configuration.changes and see how that works for
> you.
>
> Good luck
>
> On Fri, May 9, 2008 at 4:47 PM, Michael Satterwhite <michael
weblore.com>
> wrote:
> > I'm trying to turn off magic quotes for a site. I've copied the php.ini
> > from /etc/php5/apache2 to the web site directory. In this file, I've
> changed
> > magic_quotes_gpc to read
> > magic_quotes.gpc = Off
> >
> > When I run phpinfo() from this directory, it still shows magic quotes as
> being
> > on. I'm guessing there is another configuration parameter (either in the
> > Apache configuration or for php) that allows this to be processed. Would
> > someone be so kind as to help me here; I admit ignorance.
> >
> > ---Michael
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
Michael Satterwhite wrote:
> I'm trying to turn off magic quotes for a site. I've copied the php.ini
> from /etc/php5/apache2 to the web site directory. In this file, I've changed
> magic_quotes_gpc to read
> magic_quotes.gpc = Off
>
> When I run phpinfo() from this directory, it still shows magic quotes as being
> on. I'm guessing there is another configuration parameter (either in the
> Apache configuration or for php) that allows this to be processed. Would
> someone be so kind as to help me here; I admit ignorance.
>
> ---Michael
You have to set it in your main php.ini, the one shown in phpinfo() or
set it in a .htaccess in the web dir if permitted. You can't just copy
a php.ini into a dir and expect php to use it.
-Shawn
attached mail follows:
On Friday 09 May 2008 11:56:32 Thiago Pojda wrote:
> phpinfo() should also tell you what php.ini is loaded.
>
> Did you check that?
I hadn't thought to, but I just did. As expected, it's reading it
from /etc/php5/apache2.
attached mail follows:
On Friday 09 May 2008 11:59:25 Wolf wrote:
> When making changes to Apache configuration read files, you have to RESTART
> APACHE before those changes take effect.
>
> However you can use php's ini_set () function to set a number of settings
> on the fly that can be changed per page change.
As this is (should be) being read from the user directory containing the
application instead of the global configuration file, I'd expect it to behave
more like the .htaccess file. The use of .htaccess to override apache
configurations doesn't require an apache restart.
I do know that on bluehost, they actually encourage people to use their own
php.ini file in their web directory ... and users certainly don't have the
authority to restart apache.
That said - just for grins, I *DID* restart apache2. It made no difference.
attached mail follows:
On Fri, May 9, 2008 at 12:02 PM, Michael Satterwhite <michael
weblore.com>
wrote:
> I do know that on bluehost, they actually encourage people to use their own
> php.ini file in their web directory ... and users certainly don't have the
> authority to restart apache.
>
> That said - just for grins, I *DID* restart apache2. It made no difference.
(from before) /etc/php5/apache2 is a centralized directory; i surprised you
even have access to it on a shared host. do you have your own instance of
linux? either way i sincerely doubt thats the web directory. i would try
putting a .htaccess file in your web root.
php_flag magic_quotes_gpc = Off
when you look at the output of phpinfo() there will be 2 columns. one has
the heading 'master value' the other has the heading 'local value' is the
local value different than the master value? it should be if the .htaccess
file is working correctly (though you many not have permission to use them
[but it is typical to allow php configuration via .htaccess on shared
hosts]).
-nathan
attached mail follows:
Nathan Nobbe wrote:
> On Fri, May 9, 2008 at 12:02 PM, Michael Satterwhite <michael
weblore.com>
> wrote:
>
>
>> I do know that on bluehost, they actually encourage people to use their own
>> php.ini file in their web directory ... and users certainly don't have the
>> authority to restart apache.
>>
>> That said - just for grins, I *DID* restart apache2. It made no difference.
>>
Some web hosts allow you have have your own local php.ini. You just
create an empty php.ini file in your main web directory. After you do
that, the loaded configuration file shown in the output from phpinfo()
will show the path to the local php.ini file. Then, just put the
specific directive in there, such as:
magic_quotes_gpc = Off
This works on some hosts.
Janet
--
----------------
janet.valade.com
attached mail follows:
bouncing back to the list..
---------- Forwarded message ----------
From: Michael Satterwhite <michael
weblore.com>
Date: Fri, May 9, 2008 at 3:09 PM
Subject: Re: [PHP] php.ini
To: Nathan Nobbe <quickshiftin
gmail.com>
On Friday 09 May 2008 13:43:27 you wrote:
> On Fri, May 9, 2008 at 12:02 PM, Michael Satterwhite <michael
weblore.com>
>
> wrote:
> > I do know that on bluehost, they actually encourage people to use their
> > own php.ini file in their web directory ... and users certainly don't
> > have the authority to restart apache.
> >
> > That said - just for grins, I *DID* restart apache2. It made no
> > difference.
>
> (from before) /etc/php5/apache2 is a centralized directory; i surprised
you
> even have access to it on a shared host. do you have your own instance of
> linux? either way i sincerely doubt thats the web directory. i would try
> putting a .htaccess file in your web root.
I never said it was the web directory ... I said that's where php.ini is
being
loaded from. The web directory is /var/www ... that's where the php.ini I
*WANT* loaded is. ...and, yes, I have my own Linux machine that I use for
testing.
> php_flag magic_quotes_gpc = Off
>
> when you look at the output of phpinfo() there will be 2 columns. one has
> the heading 'master value' the other has the heading 'local value' is
the
> local value different than the master value? it should be if the
.htaccess
> file is working correctly (though you many not have permission to use them
> [but it is typical to allow php configuration via .htaccess on shared
> hosts]).
I've tried that now, and it does work. I was trying to do it through a local
php.ini because I know that's the way bluehost makes us do it, and there are
several websites that document it as a working manner.
I do thank everyone for their help with this.
attached mail follows:
There was a typo in my previous message asking the question. I typed a "."
instead of "_". It's corrected below:
On Friday 09 May 2008 11:47:29 Michael Satterwhite wrote:
> I'm trying to turn off magic quotes for a site. I've copied the php.ini
> from /etc/php5/apache2 to the web site directory. In this file, I've
> changed magic_quotes_gpc to read
> magic_quotes_gpc = Off
>
> When I run phpinfo() from this directory, it still shows magic quotes as
> being on. I'm guessing there is another configuration parameter (either in
> the Apache configuration or for php) that allows this to be processed.
> Would someone be so kind as to help me here; I admit ignorance.
>
> ---Michael
attached mail follows:
Hi Everyone,
SO it's friday, I'm tired, and I can't seem to think straight... I am
attempting to do some very basic math with some arrays... Here's the
pseudo code that I'm working with:
NumberOfPieces * PieceWeight = TotalWeight
explode total weight to get tenth's of pounds, then divide tenth's of
pounds by 16 to grab ounces.
Display TotalWeight # Exploded Ounces.
Which I have working just fine for a single set of boxes...
My problem is I want to be able to automatically add say 50 boxes in a
form to process the weight of each route...
So what I need to do is probably use some kind of a counter to loop
through my $RoutePieces array and multiply by the $PieceWeight?
$PieceWeight is a static number.
Now let me show you some abbreviated code to try and explain what I'm
using right now:
<?PHP
$i= "0";
$num= "2";
$PieceWeight = $_POST['txtPieceWeight'];
$RoutePieces[] = $_POST['txtRoutePieces'];
$RouteNumber[] = $_POST['txtRoute'];
$totalWeight = $PieceWeight * $RoutePieces/16;
$weightExplode = explode('.', $totalWeight);
//$weightOunces = ((float)('.' . $weightExplode[1])) * 16;
// Use stut's method... Seems cleaner
$explodeOunces = ($totalWeight - intval($totalWeight)) * 16;
while($i <= $num){
echo <<<HTML
<p>
Route Number:<input type="text" name="txtRoute[$i]" size="4" value
="{$RouteNumber[$i]}"> Number of pieces: <input type="text"
name="txtRoutePieces[$i]" size="4"
value="{$RoutePieces[$i]}"><label>Total weight of route:
{$weightExplode[0]} # {$explodeOunces} Ounces</label>
</p>
HTML;
$i++;
echo $i;
}
?>
the $_POST array has the proper values stored properly... I just can't
seem to figure out how to work with the values... Any ideas? Or slaps
on the back of the head to wake me up a little? :)
I need help :P
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruim
raoset.com
attached mail follows:
On Fri, May 9, 2008 at 12:56 PM, Jason Pruim <japruim
raoset.com> wrote:
> Hi Everyone,
>
> SO it's friday, I'm tired, and I can't seem to think straight... I am
> attempting to do some very basic math with some arrays... Here's the pseudo
> code that I'm working with:
>
> NumberOfPieces * PieceWeight = TotalWeight
>
> explode total weight to get tenth's of pounds, then divide tenth's of
> pounds by 16 to grab ounces.
>
> Display TotalWeight # Exploded Ounces.
>
> Which I have working just fine for a single set of boxes...
>
> My problem is I want to be able to automatically add say 50 boxes in a form
> to process the weight of each route...
>
> So what I need to do is probably use some kind of a counter to loop through
> my $RoutePieces array and multiply by the $PieceWeight? $PieceWeight is a
> static number.
>
> Now let me show you some abbreviated code to try and explain what I'm using
> right now:
> <?PHP
> $i= "0";
> $num= "2";
> $PieceWeight = $_POST['txtPieceWeight'];
> $RoutePieces[] = $_POST['txtRoutePieces'];
> $RouteNumber[] = $_POST['txtRoute'];
>
> $totalWeight = $PieceWeight * $RoutePieces/16;
> $weightExplode = explode('.', $totalWeight);
> //$weightOunces = ((float)('.' . $weightExplode[1])) * 16;
> // Use stut's method... Seems cleaner
> $explodeOunces = ($totalWeight - intval($totalWeight)) * 16;
>
> while($i <= $num){
> echo <<<HTML
>
> <p>
> Route Number:<input type="text" name="txtRoute[$i]" size="4" value
> ="{$RouteNumber[$i]}"> Number of pieces: <input type="text"
> name="txtRoutePieces[$i]" size="4" value="{$RoutePieces[$i]}"><label>Total
> weight of route: {$weightExplode[0]} # {$explodeOunces} Ounces</label>
> </p>
>
>
> HTML;
>
> $i++;
> echo $i;
> }
> ?>
>
> the $_POST array has the proper values stored properly... I just can't seem
> to figure out how to work with the values... Any ideas? Or slaps on the back
> of the head to wake me up a little? :)
>
> I need help :P
>
>
>
> --
>
> Jason Pruim
> Raoset Inc.
> Technology Manager
> MQC Specialist
> 3251 132nd ave
> Holland, MI, 49424-9337
> www.raoset.com
> japruim
raoset.com
>
>
>
>
Rather than a counter, you could use foreach:
foreach ( $RoutePieces as $key => $value )
{
$blah = $value * $PieceWeight;
}
Make sense?
--
-Dan Joseph
www.canishosting.com - Plans start
$1.99/month. Reseller plans and
Dedicated servers available.
"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."
attached mail follows:
At 12:56 PM -0400 5/9/08, Jason Pruim wrote:
>Hi Everyone,
>
>SO it's friday, I'm tired, and I can't seem to think straight... I
>am attempting to do some very basic math with some arrays... Here's
>the pseudo code that I'm working with:
>
>NumberOfPieces * PieceWeight = TotalWeight
>
>explode total weight to get tenth's of pounds, then divide tenth's
>of pounds by 16 to grab ounces.
What??
Why do you want tenth's of pounds? Just divide pounds by 16 and
you'll get ounces.
---
>Display TotalWeight # Exploded Ounces.
>
>Which I have working just fine for a single set of boxes...
>
>My problem is I want to be able to automatically add say 50 boxes in
>a form to process the weight of each route...
How much does each box weight and how many boxes? That's all you need.
---
>So what I need to do is probably use some kind of a counter to loop
>through my $RoutePieces array and multiply by the $PieceWeight?
>$PieceWeight is a static number.
Is $PieceWeight is a static number?
The last time I checked, the cost per oz for shipping depends upon
the weight. The more weight, the less the cost per ounce. Is that not
true?
---
As for the code, that's pretty simple.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
On May 9, 2008, at 1:05 PM, Dan Joseph wrote:
> On Fri, May 9, 2008 at 12:56 PM, Jason Pruim <japruim
raoset.com>
> wrote:
>
>> Hi Everyone,
>>
>> SO it's friday, I'm tired, and I can't seem to think straight... I am
>> attempting to do some very basic math with some arrays... Here's
>> the pseudo
>> code that I'm working with:
>>
>> NumberOfPieces * PieceWeight = TotalWeight
>>
>> explode total weight to get tenth's of pounds, then divide tenth's of
>> pounds by 16 to grab ounces.
>>
>> Display TotalWeight # Exploded Ounces.
>>
>> Which I have working just fine for a single set of boxes...
>>
>> My problem is I want to be able to automatically add say 50 boxes
>> in a form
>> to process the weight of each route...
>>
>> So what I need to do is probably use some kind of a counter to loop
>> through
>> my $RoutePieces array and multiply by the $PieceWeight?
>> $PieceWeight is a
>> static number.
>>
>> Now let me show you some abbreviated code to try and explain what
>> I'm using
>> right now:
>> <?PHP
>> $i= "0";
>> $num= "2";
>> $PieceWeight = $_POST['txtPieceWeight'];
>> $RoutePieces[] = $_POST['txtRoutePieces'];
>> $RouteNumber[] = $_POST['txtRoute'];
>>
>> $totalWeight = $PieceWeight * $RoutePieces/16;
>> $weightExplode = explode('.', $totalWeight);
>> //$weightOunces = ((float)('.' . $weightExplode[1])) * 16;
>> // Use stut's method... Seems cleaner
>> $explodeOunces = ($totalWeight - intval($totalWeight)) * 16;
>>
>> while($i <= $num){
>> echo <<<HTML
>>
>> <p>
>> Route Number:<input type="text" name="txtRoute[$i]" size="4"
>> value
>> ="{$RouteNumber[$i]}"> Number of pieces: <input type="text"
>> name="txtRoutePieces[$i]" size="4"
>> value="{$RoutePieces[$i]}"><label>Total
>> weight of route: {$weightExplode[0]} # {$explodeOunces} Ounces</
>> label>
>> </p>
>>
>>
>> HTML;
>>
>> $i++;
>> echo $i;
>> }
>> ?>
>>
>> the $_POST array has the proper values stored properly... I just
>> can't seem
>> to figure out how to work with the values... Any ideas? Or slaps on
>> the back
>> of the head to wake me up a little? :)
>>
>> I need help :P
>>
>>
>>
>> --
>>
>> Jason Pruim
>> Raoset Inc.
>> Technology Manager
>> MQC Specialist
>> 3251 132nd ave
>> Holland, MI, 49424-9337
>> www.raoset.com
>> japruim
raoset.com
>>
>>
>>
>>
> Rather than a counter, you could use foreach:
>
> foreach ( $RoutePieces as $key => $value )
> {
> $blah = $value * $PieceWeight;
> }
>
> Make sense?
The idea make sense, and I think it will work. But I'm getting this
error:
[Fri May 9 13:19:33 2008] [error] PHP Fatal error: Unsupported
operand types in /Volumes/RAIDer/webserver/Documents/dev/weightcalc/
index.php on line 22
foreach ($RoutePieces as $key => $value){
$testWeight = $value * $PieceWeight; <-------Line 22
}
Some quick trying tells me that the problem is my "*" I don't remember
having this problem before. Is there another character I should use to
multiply with? :)
Thanks for looking!
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruim
raoset.com
attached mail follows:
Hey tedd
On May 9, 2008, at 1:21 PM, tedd wrote:
> At 12:56 PM -0400 5/9/08, Jason Pruim wrote:
>> Hi Everyone,
>>
>> SO it's friday, I'm tired, and I can't seem to think straight... I
>> am attempting to do some very basic math with some arrays... Here's
>> the pseudo code that I'm working with:
>>
>> NumberOfPieces * PieceWeight = TotalWeight
>>
>> explode total weight to get tenth's of pounds, then divide tenth's
>> of pounds by 16 to grab ounces.
>
> What??
>
> Why do you want tenth's of pounds? Just divide pounds by 16 and
> you'll get ounces.
It's actually for a weight calculator that we use for some of our
mailings. when you take .226 and multiply that by 464 you get 104.864
ounces.
I need to be able to display that as: 6 # 13.824 Ounces.
>
>
> ---
>
>> Display TotalWeight # Exploded Ounces.
>>
>> Which I have working just fine for a single set of boxes...
>>
>> My problem is I want to be able to automatically add say 50 boxes
>> in a form to process the weight of each route...
>
> How much does each box weight and how many boxes? That's all you need.
the routes can have anywhere from 1 piece to 800+ pieces. and we can
have as few as 1 route to as many as 50 or 60+
>
>
> ---
>
>> So what I need to do is probably use some kind of a counter to loop
>> through my $RoutePieces array and multiply by the $PieceWeight?
>> $PieceWeight is a static number.
>
> Is $PieceWeight is a static number?
>
> The last time I checked, the cost per oz for shipping depends upon
> the weight. The more weight, the less the cost per ounce. Is that
> not true?
Normally yes, but not in this case :) I'm using it so I don't have to
sit there and count out 464 postcards. I can just throw them on my
scale and get the total weight.
>
>
> ---
>
> As for the code, that's pretty simple.
Then it's a simple "It's a friday thing" for me... My wife keeps
rubbing in that today is her last day of work until mid august... :P
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruim
raoset.com
attached mail follows:
At 1:29 PM -0400 5/9/08, Jason Pruim wrote:
>Hey tedd
>
>On May 9, 2008, at 1:21 PM, tedd wrote:
>
>>At 12:56 PM -0400 5/9/08, Jason Pruim wrote:
>>>Hi Everyone,
>>>
>>>SO it's friday, I'm tired, and I can't seem to think straight... I
>>>am attempting to do some very basic math with some arrays...
>>>Here's the pseudo code that I'm working with:
>>>
>>>NumberOfPieces * PieceWeight = TotalWeight
>>>
>>>explode total weight to get tenth's of pounds, then divide tenth's
>>>of pounds by 16 to grab ounces.
>>
>>What??
>>
>>Why do you want tenth's of pounds? Just divide pounds by 16 and
>>you'll get ounces.
>
>It's actually for a weight calculator that we use for some of our
>mailings. when you take .226 and multiply that by 464 you get
>104.864 ounces.
>
>I need to be able to display that as: 6 # 13.824 Ounces.
Well, that explains it. Now, it's Friday for me.
You know, if you take the total weight and divide that by the number
of gorillas per lamp-pole you'll go back in time. I'm totally lost.
Sorry I couldn't be more help.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
Jason Pruim wrote:
>> Why do you want tenth's of pounds? Just divide pounds by 16 and you'll
>> get ounces.
>
> It's actually for a weight calculator that we use for some of our
> mailings. when you take .226 and multiply that by 464 you get 104.864
> ounces.
>
> I need to be able to display that as: 6 # 13.824 Ounces.
Then I think you want to use the mod operator:
(I'm assuming .226 is the cost per ounce and 464 is the total number of
ounces)
$pounds = intval( .226 * 464 / 16 );
$ounces = ( .226 * 464 ) % 16;
Roberto
attached mail follows:
Roberto Mansfield wrote:
> (I'm assuming .226 is the cost per ounce and 464 is the total number of
> ounces)
It sure is Friday. This assumption doesn't make any sense!
attached mail follows:
On May 9, 2008, at 4:23 PM, Roberto Mansfield wrote:
> Roberto Mansfield wrote:
>
>> (I'm assuming .226 is the cost per ounce and 464 is the total
>> number of
>> ounces)
>
> It sure is Friday. This assumption doesn't make any sense!
Yeah... and my work day is almost done! SO Happy Friday to you all!
Basically though, .226 is the weight of a single piece. we get it by
weighing 100 pieces, and then dividing the total weight by 100. that
gives us the weight of a single piece in a tenth of a pound. And I
need to display in pounds and ounces. I have that part figured out, I
just need to fight with it so I can do it without having to type out
in the code 50 fields to add the routes together :)
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruim
raoset.com
attached mail follows:
---- bobcray <bobcray
pacbell.net> wrote:
> unsubscribe
http://www.php.net and unsubscribe yourself.
attached mail follows:
On May 9, 2008, at 2:39 PM, Wolf wrote:
>
> ---- bobcray <bobcray
pacbell.net> wrote:
>> unsubscribe
>
> http://www.php.net and unsubscribe yourself.
Or look at the bottom of ANY message posted to the list and look for
this line:
>
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
Just a thought :)
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruim
raoset.com
attached mail follows:
At 2:39 PM -0400 5/9/08, Wolf wrote:
>---- bobcray <bobcray
pacbell.net> wrote:
>> unsubscribe
>
>http://www.php.net and unsubscribe yourself.
Yeah, I got that sent to me as well.
It's interesting when people are smart enough to subscribe, but
dummy-up when exiting. Do you think this list saps intelligence?
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
I have an xml file with a cdata element like the one below. How would I
use the php xml functions to extract that cdata and save it as a pdf file?
<attach id="2" display-name="207069.pdf" file-name="207069.pdf"
obj-type="1" system="0">
<![CDATA[eJysumVQW1/0NtoWK95CcXe3EFxK8QDBCQ5 ...... ]]>
</attach>
The code I have is this...
$in = fopen("test.xml", 'r');
$XMLStr = '';
while (!feof($in)) {
$LineNumber++;
$XMLStr .= fgets($in);
}
$XML = simplexml_load_string($XMLStr);
foreach($XML->props->attachments->attach as $Attachment){
print_r($Attachment);
}
The output looks like this...
SimpleXMLElement Object
(
[
attributes] => Array
(
[id] => 2
[display-name] => 207069.pdf
[file-name] => 207069.pdf
[obj-type] => 1
[system] => 0
)
)
--
Chris W
KE5GIX
"Protect your digital freedom and privacy, eliminate DRM,
learn more at http://www.defectivebydesign.org/what_is_drm"
Ham Radio Repeater Database.
http://hrrdb.com
attached mail follows:
Hi,
i'm trying to build a class that sorts a multidimensional array.
I'm using the php function "usort".
I declared the comparision function as a method of my class but i'm unable to give it as argument to the function usort.
this "usort($this->arr, $this->cmpi)" gaves the following error: usort() [function.usort]: Invalid comparison function
i tried to do "usort($this->arr, 'cmpi')" but it does not work either.
Thanks
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
attached mail follows:
> i'm trying to build a class that sorts a multidimensional array.
> I'm using the php function "usort".
>
> I declared the comparision function as a method of my class but i'm unable to give it as argument to the function usort.
>
> this "usort($this->arr, $this->cmpi)" gaves the following error: usort() [function.usort]: Invalid comparison function
>
> i tried to do "usort($this->arr, 'cmpi')" but it does not work either.
If it's anything like other functions, try this:
usort($this->arr, array($this, 'cmpi'));
--
Richard Heyes
+----------------------------------------+
| Access SSH with a Windows mapped drive |
| http://www.phpguru.org/sftpdrive |
+----------------------------------------+
attached mail follows:
It works thanks a lot!
--- On Fri, 5/9/08, Richard Heyes <richardh
phpguru.org> wrote:
> From: Richard Heyes <richardh
phpguru.org>
> Subject: Re: [PHP] usort inside a class
> To: itmaqurfe
yahoo.com
> Cc: php-general
lists.php.net
> Date: Friday, May 9, 2008, 8:47 PM
> > i'm trying to build a class that sorts a
> multidimensional array.
> > I'm using the php function "usort".
> >
> > I declared the comparision function as a method of my
> class but i'm unable to give it as argument to the
> function usort.
> >
> > this "usort($this->arr, $this->cmpi)"
> gaves the following error: usort() [function.usort]:
> Invalid comparison function
> >
> > i tried to do "usort($this->arr,
> 'cmpi')" but it does not work either.
>
> If it's anything like other functions, try this:
>
> usort($this->arr, array($this, 'cmpi'));
>
> --
> Richard Heyes
>
> +----------------------------------------+
> | Access SSH with a Windows mapped drive |
> | http://www.phpguru.org/sftpdrive |
> +----------------------------------------+
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
attached mail follows:
Please include the list when replying, unless you're willing to pay my
standard hourly rate.
On 9 May 2008, at 20:49, Matthew Gonzales wrote:
> Thanks for the responses. I think that I need to clarify.
>
> I am looking to use an include to minimize the amount of code on the
> page. So I wanted to use an include to call the code from another
> file. They are functions that query and update the databse and move
> uploaded files. Hope this make more sense.
That's fine, just be sure not to include the file more than once per
request or you'll get error messages regarding redeclaration of
functions. You can also use the _once variations of include or require
to get around this but bear in mind this causes a small performance hit.
-Stut
--
http://stut.net/
> Stut wrote:
>> On 9 May 2008, at 18:56, Bradley Stahl wrote:
>>> Your code would essentially be "inserted" in the place where your
>>> include
>>> statement is called. Let's say that your in 'page.php' you had the
>>> following code:
>>>
>>> echo "I AM IN PAGE.PHP!";
>>>
>>> and then in your script you have your code:
>>>
>>> if (some variable) {
>>> include('page.php');
>>> }
>>>
>>>
>>> This would essentially be giving you the code:
>>>
>>> if(some variable) {
>>> echo "I AM IN PAGE.PHP!";
>>> }
>>>
>>> I hope that this makes sense.. and this helps!
>>
>> That's not quite right and I think it's important to understand
>> exactly what PHP does here.
>>
>> PHP is executing a file and encounters file inclusion (include/
>> require(_once)). PHP will load and compile the included file.
>> During this stage it registers declarations in the global scope,
>> i.e. classes and functions. After that it executes the included
>> file in the same context from which it was included, so all local
>> vars visible inside your if block will be accessible. Once that
>> file's done PHP returns to executing the original file from the
>> statement after the include.
>>
>> Note that no code insertion takes place, it purely passes execution
>> to the included file. It's this sequence that prevents you from
>> defining a class across several files.
>>
>> Hope that makes it clearer.
>>
>> -Stut
>>
>
> --
> Matthew Gonzales
> IT Professional Specialist
> Enterprise Information Technology Services
> University of Georgia
> Email: matt323
uga.edu <mailto:matt323
uga.edu>
> Phone: (706)542-9538
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]