php-general Digest 12 Apr 2012 07:05:28 -0000 Issue 7772
Topics (messages 317530 through 317539):
Re: Sorting Help
317530 by: admin
317531 by: Floyd Resler
317532 by: Stuart Dallas
317533 by: Bastien
Re: a fractal of bad design
317534 by: Daevid Vincent
317535 by: Jay Blanchard
317538 by: Paul M Foster
317539 by: Simon Schick
Re: php in windows
317536 by: Kirk Bailey
317537 by: Daniel Fenn
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
-----Original Message-----
From: Floyd Resler [mailto:fres...@adex-intl.com]
Sent: Wednesday, April 11, 2012 11:26 AM
To: PHP
Subject: [PHP] Sorting Help
I need to sort the following array:
{
[Smith, Bob]=>array(137.5,125.5),
[Jones, Robert]=>array(132.7,128.2)
}
The array needs to be sorted by the first number (i.e. 137.5) and then the
second in descending order. I looked at array_multisort but couldn't figure
out how to make work for my needs.
Thanks!
Floyd
Here is what I did to your array
$test = array("Smith, Bob"=>array(137.5,125.5),"Jones
Robert"=>array(132.7,128.2));
asort($test);
print_r('<pre>');
print_r($test);
--- End Message ---
--- Begin Message ---
On Apr 11, 2012, at 1:11 PM, admin wrote:
>
>
> -----Original Message-----
> From: Floyd Resler [mailto:fres...@adex-intl.com]
> Sent: Wednesday, April 11, 2012 11:26 AM
> To: PHP
> Subject: [PHP] Sorting Help
>
> I need to sort the following array:
> {
> [Smith, Bob]=>array(137.5,125.5),
> [Jones, Robert]=>array(132.7,128.2)
> }
>
> The array needs to be sorted by the first number (i.e. 137.5) and then the
> second in descending order. I looked at array_multisort but couldn't figure
> out how to make work for my needs.
>
> Thanks!
> Floyd
>
>
>
> Here is what I did to your array
>
> $test = array("Smith, Bob"=>array(137.5,125.5),"Jones
> Robert"=>array(132.7,128.2));
> asort($test);
> print_r('<pre>');
> print_r($test);
>
>
That almost worked. I did an arsort() and got the following:
Array
(
[Guy, Matt] => Array
(
[0] => 164.67
[1] => 135.67
)
[Smith, Toby] => Array
(
[0] => 159.33
[1] => 132.33
)
[Young, Matt] => Array
(
[0] => 157.67
[1] => 131.67
)
[Shobe, Dale ] => Array
(
[0] => 157.67
[1] => 128.67
)
[King, Derrick] => Array
(
[0] => 155.67
[1] => 126.67
)
[Reynolds, Jeff] => Array
(
[0] => 155.67
[1] => 133.67
)
[Bobo, Tom] => Array
(
[0] => 152.33
[1] => 124.33
)
[Henderson, Cody] => Array
(
[0] => 150.33
[1] => 121.33
)
[McGuffin, Jimmy] => Array
(
[0] => 145.67
[1] => 118.67
)
[Stone, Richard] => Array
(
[0] => 145
[1] => 119.00
)
[Biggerstaff, David ] => Array
(
[0] => 142.33
[1] => 115.33
)
[Dennis, Daymon] => Array
(
[0] => 142
[1] => 114.00
)
[Bush, Duke] => Array
(
[0] => 141
[1] => 121.00
)
}
That's not the entire array but it sorts just fine except for two entries. For
some reason these two aren't sorting in descending order of the second element:
[King, Derrick] => Array
(
[0] => 155.67
[1] => 126.67
)
[Reynolds, Jeff] => Array
(
[0] => 155.67
[1] => 133.67
)
Everything else sorts just fine. I'm not sure why that is.
Thanks!
Floyd
--- End Message ---
--- Begin Message ---
On 11 Apr 2012, at 16:26, Floyd Resler wrote:
> I need to sort the following array:
> {
> [Smith, Bob]=>array(137.5,125.5),
> [Jones, Robert]=>array(132.7,128.2)
> }
>
> The array needs to be sorted by the first number (i.e. 137.5) and then the
> second in descending order. I looked at array_multisort but couldn't figure
> out how to make work for my needs.
Use a custom sorting function, then you can sort any way you want:
http://php.net/usort
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--- End Message ---
--- Begin Message ---
Bastien Koert
On 2012-04-11, at 2:18 PM, Floyd Resler <fres...@adex-intl.com> wrote:
>
> On Apr 11, 2012, at 1:11 PM, admin wrote:
>
>>
>>
>> -----Original Message-----
>> From: Floyd Resler [mailto:fres...@adex-intl.com]
>> Sent: Wednesday, April 11, 2012 11:26 AM
>> To: PHP
>> Subject: [PHP] Sorting Help
>>
>> I need to sort the following array:
>> {
>> [Smith, Bob]=>array(137.5,125.5),
>> [Jones, Robert]=>array(132.7,128.2)
>> }
>>
>> The array needs to be sorted by the first number (i.e. 137.5) and then the
>> second in descending order. I looked at array_multisort but couldn't figure
>> out how to make work for my needs.
>>
>> Thanks!
>> Floyd
>>
>>
>>
>> Here is what I did to your array
>>
>> $test = array("Smith, Bob"=>array(137.5,125.5),"Jones
>> Robert"=>array(132.7,128.2));
>> asort($test);
>> print_r('<pre>');
>> print_r($test);
>>
>>
>
> That almost worked. I did an arsort() and got the following:
> Array
> (
> [Guy, Matt] => Array
> (
> [0] => 164.67
> [1] => 135.67
> )
>
> [Smith, Toby] => Array
> (
> [0] => 159.33
> [1] => 132.33
> )
>
> [Young, Matt] => Array
> (
> [0] => 157.67
> [1] => 131.67
> )
>
> [Shobe, Dale ] => Array
> (
> [0] => 157.67
> [1] => 128.67
> )
>
> [King, Derrick] => Array
> (
> [0] => 155.67
> [1] => 126.67
> )
>
> [Reynolds, Jeff] => Array
> (
> [0] => 155.67
> [1] => 133.67
> )
>
> [Bobo, Tom] => Array
> (
> [0] => 152.33
> [1] => 124.33
> )
>
> [Henderson, Cody] => Array
> (
> [0] => 150.33
> [1] => 121.33
> )
>
> [McGuffin, Jimmy] => Array
> (
> [0] => 145.67
> [1] => 118.67
> )
>
> [Stone, Richard] => Array
> (
> [0] => 145
> [1] => 119.00
> )
>
> [Biggerstaff, David ] => Array
> (
> [0] => 142.33
> [1] => 115.33
> )
>
> [Dennis, Daymon] => Array
> (
> [0] => 142
> [1] => 114.00
> )
>
> [Bush, Duke] => Array
> (
> [0] => 141
> [1] => 121.00
> )
> }
>
> That's not the entire array but it sorts just fine except for two entries.
> For some reason these two aren't sorting in descending order of the second
> element:
> [King, Derrick] => Array
> (
> [0] => 155.67
> [1] => 126.67
> )
>
> [Reynolds, Jeff] => Array
> (
> [0] => 155.67
> [1] => 133.67
> )
> Everything else sorts just fine. I'm not sure why that is.
>
> Thanks!
> Floyd
>
Check that you don't have a space in front of those values. That could cause
some confusion.
--- End Message ---
--- Begin Message ---
http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/
Can't say he doesn't have some good points, but he sure goes about it in a
dickish way.
--- End Message ---
--- Begin Message ---
On 4/11/2012 7:06 PM, Daevid Vincent wrote:
http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/
Can't say he doesn't have some good points, but he sure goes about it in a
dickish way.
Yes, he does have some good points and most, if not all, of those points
have been discussed on this list more than once. The problem with people
like this is that they choose not to contribute to solving the issues by
working with the dev team and perhaps even taking a leadership role.
I really am tired of hearing how "bad" PHP is. I use it every day and I
have used it for over a decade. Some things are difficult to accomplish
(re: the thread where Robert helped me tremendously over the past couple
of weeks). I have been tasked lately with updating and maintaining some
.net and classic ASP sites and believe me when I say that bad
programmers/developers make any language crap. I would love it of
languages were more consistent and concise across the board! For a
simple website C# is just as much overkill as anything else, not to
mention that the developer tools are expensive and come with a learning
curve all of their own.
Yes, there are nuances and inconsistencies. The same goes for any
language you care to trot out.
--- End Message ---
--- Begin Message ---
On Wed, Apr 11, 2012 at 05:06:10PM -0700, Daevid Vincent wrote:
> http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/
>
> Can't say he doesn't have some good points, but he sure goes about it in a
> dickish way.
Wow. I wish I could find something that complete for Javascript.
Paul
--
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com
--- End Message ---
--- Begin Message ---
2012/4/12 Daevid Vincent <dae...@daevid.com>:
> http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/
>
> Can't say he doesn't have some good points, but he sure goes about it in a
> dickish way.
Hi, Daevid
I think this discussion is incomplete without mentioning the feedback
from Anthony Ferrara:
http://blog.ircmaxell.com/2012/04/php-sucks-but-i-like-it.html
Bye
Simon
--- End Message ---
--- Begin Message ---
Steve, THERE IS NO SUCH FILE in tinyweb. It turns to the operating
system asspciations to determine what to use to process the cgi,
then captures the returned stdio output and feeds THAT back as part
of the data stream back down the stack. Therefore, it is not
interfacing with the windows operating system properly, and as I do
not speak delphi, I am not sure how to go through the sourcecode and
rectify this.
If you like, I cna provide a link to the installer that adds it to a
windows computer so you can take a look- if you or anyone else is
interested. Oddly enough, it appears to handle python fine, and is
reported by others to also handle perl.
Kirk,
You have to tell your "tinyweb" what to do with the .php extensions... in
the config of the webserver, you will have to add a line saying where the
php binary is, or uncomment it (as it probably already exists) and restart
the webserver.
As it appears to me, since you can have some "code" on the screen, your
server does not know how to deal with it, so it will treat it like a text
file, and just spew the code out. Once you have it pointing to the php
binary, it will work.
Good luck!
Steve Staples.
--- End Message ---
--- Begin Message ---
I don't want to sound rude but I did say this before, why don't you
get zend server CE or xampp and install that?
On Thu, Apr 12, 2012 at 12:11 PM, Kirk Bailey <kbai...@howlermonkey.net> wrote:
> Steve, THERE IS NO SUCH FILE in tinyweb. It turns to the operating system
> asspciations to determine what to use to process the cgi, then captures the
> returned stdio output and feeds THAT back as part of the data stream back
> down the stack. Therefore, it is not interfacing with the windows operating
> system properly, and as I do not speak delphi, I am not sure how to go
> through the sourcecode and rectify this.
> If you like, I cna provide a link to the installer that adds it to a windows
> computer so you can take a look- if you or anyone else is interested. Oddly
> enough, it appears to handle python fine, and is reported by others to also
> handle perl.
>
>> Kirk,
>>
>> You have to tell your "tinyweb" what to do with the .php extensions... in
>> the config of the webserver, you will have to add a line saying where the
>> php binary is, or uncomment it (as it probably already exists) and restart
>> the webserver.
>>
>>
>> As it appears to me, since you can have some "code" on the screen, your
>> server does not know how to deal with it, so it will treat it like a text
>> file, and just spew the code out. Once you have it pointing to the php
>> binary, it will work.
>>
>> Good luck!
>>
>> Steve Staples.
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---