« first day (1726 days earlier)      last day (3225 days later) » 

9:00 AM
 
@Sherif great, thanks!
 
Mornbo
 
Morning
 
1
A: Generating a random password in php

Scott ArciszewskiSince you are generating a password, you need to ensure that the password you generate is unpredictable, and the only way to ensure this property is present in your implementation is to use a cryptographically secure pseudorandom number generator (CSPRNG). The requirement for a CSPRNG can be rel...

since I am now able to, I've submitted a CSPRNG-powered answer ;)
 
I'm building a web chat app which users can send msgs or photos .. but I'm looking for a method to protect server from load
What about save users' photos on amazon s3 hosting and access files by tokens ?
Or should I buy another servers to fit the increasement of users data ?
 
9:10 AM
@ScottArciszewski I'd put the tldr at the top
 
@ScottArciszewski great
 
10:05 AM
@ScottArciszewski For large ranges, use GMP?
 
I can look into GMP support, but is it part of the default install for everyone? :)
 
@ScottArciszewski no, it's not enabled by default
 
ah ok
I'll still file a ticket for it :)
 
for what?
 
for random_compat? :P
 
10:15 AM
Morenignfginfdignfignfign
 
@ScottArciszewski ah right. attention span zero ^^
 
Guys
is there anyway to backup a mysql DB from remote host to local
mysqldump command do the thing
but the backup appending file will be created on the remote host
i want to create it on the local PC
 
@NikiC TEAMWORK!
Also, you should know that @asgrim is sitting right in front of me, so if you want me to throw sharp items at him, just lemme know.
 
@underscore Can you access the remote MySQL from local ssh?
 
no
using ssh root@host.com
then mysqldump
 
10:31 AM
you have ssh, and hence sftp.
 
Yup go sFTP route
 
IS there anyway to use ssh remote SET variable inside locally
 
Gordon Singleton C.M. (born 9 August 1956) is a past world-record holding Canadian cyclist. In 1982, he became the first Canadian cyclist to win a world championship, and he was the first, and only, cyclist in history to simultaneously hold world records in all three of cycling's sprint races: the 200m, 500m and 1000m distances. An Olympic racer, he was deprived of competing in the 1980 Olympics at the peak of his career by Canada's boycott of the those games in Moscow. == Early career == Singleton entered cycling at the age of 17 in 1974, when he raced for the St. Catharine's cycling club. His...
@Gordon
Was looking for this ^
 
@webfarto, when did you get a sensible username? -_-
 
@WEBFARTO
:-D
@Fabor I actually typed that before I saw your message, astounded sir, good form
 
10:36 AM
lol
 
Shut up Fapor and Jerko
 
Look @PeeHaa, @WebFarto is back
@DejanMarjanovic Are you coming to PHPSC / PHPNW this year? :-)
 
@DejanMarjanovic A wild domainwhore appears
 
user image
2
@DejanMarjanovic after too many Singletons I need a bottle of Singleton
 
I lost count of ::instance() we had
@Jimbo Would love to, just need to go beg for visa :-(
@PeeHaa I've cut my monthly expenses on useless domains, now I spend only half of salary.
 
10:49 AM
the domain webfar.to is available!
@DejanMarjanovic hi :)
 
@DejanMarjanovic Well, presumably only one if it's a singleton
 
11:19 AM
is it possible to create ai that can write its own code, like make it learn a coding language, then ask it to solve some problem and it writes a function to give an answer?
 
11:49 AM
1 message moved to Orphan GIFs
 
12:02 PM
posted on July 08, 2015 by nlecointre

/* by mElt */

 
@Fabor RSYNC!
 
@FlorianMargaine How did you time that just when I was back from lunch -_-
 
lol
 
-1
Q: php how to know if client already watch video or not and how many connections of this client?

espoomy project is to make clients to connect to videos as mp4 or m3u8 files client connect to server by username only to can watch video i want to know if this client watch video now or not ? and if client watch video now so how many people watch too by his username ? I use php but i dont know th...

 
12:25 PM
I don't understand people that love capitalism and at the same time want to use only open-source code. So in real life they have to get a wage but in IT they should use nice tools for free (communism).
 
open source is not necessarily communism
 
yeah, you have paid support
 
at work we use plenty of open source tools, and sometimes send some patches upstream too
 
I understand that they maybe want to fork and tweak and make their own version
but they don't do it and still complain
I am considering buying a license for PHPStorm 9
I've been using it for almost a month and it's much better than 7
faster, with more options and not as laggy
Btw Sencha made ExtJS paid. ~$5K per year for the basic package
 
HI
can we do this ..using just photograph materials (panorama) from google indoor view
can we create tour
is there any way using google api we can create panorama for indoor view
anybody know please reply
 
user1804599
12:39 PM
Where can I find the current status on scalar type hints?
 
@rightfold implemented in php7
what kind of status do you need?
 
@rightfold accepted rfc is here wiki.php.net/rfc/scalar_type_hints_v5
 
user1804599
Thanks.
 
1:00 PM
I always wanted to be a Software Engifar
 
@SergeyTelshevsky Whoever photoshoped that did a horrible job, btw. The guy has no legs in the distant picture.
 
@Sherif He's kneeling on his seat leaning out of the car.. obviously!
 
@SergeyTelshevsky No.
 
1:17 PM
@ziGi Communist software would be owned by a government and then licensed to you on terms favorable to said government
 
Does it make sense to run HHVM with APC? Has anyone here done it?
 
@Moak I wouldn't run anything with APC, let alone HHVM
 
hmm ... I wonder, what will be the result of China's stock implosion
 
@Machavity care to elaborate or are you just trolling?
 
@Moak APC is a discontinued project. In fact they had to roll back the last version because it was causing huge segfault issues
I've moved on to Opcache and not looked back
 
1:27 PM
@Moak no, it doesn't make any sense
 
thanks @Machavity that's a solid reason
 
@Machavity Do you have a replacement for the data caching stuff? I'm using redis but it is obviously a little slower than in-memory caching....with the benefit of not destroying the whole server.
 
@FlorianMargaine does using any accelerator cache make sense on HHVM, or is HHVM inherently supposed to be an accelerated version of php?
 
@Danack You mean besides Opcache?
 
@Machavity no I mean a replacement for the data caching functions like apc_store
 
1:32 PM
Isn't the hhvm apc implementation just a shim so the could run their 5.2 code without modifications? (only the userland storage part is implemented afaik the "opcache storage" just points to the hhvm jit
more or less equivalent to apcu for php 5.5+
 
@Danack Oh. If i need data like that cached I use memcached. I have all my sessions in there anyways (with mysql storing the data)
I would expect that APC won't be updated for PHP 7 either
 
Well, the user cache component is here: github.com/krakjoe/apcu (don't know if it runs on 5.6 or 7)
 
user895378
morning
 
mrning.
 
mning
 
1:39 PM
@Rangad It probably can run on any 5.x . PECL compiles against whatever version you're running (I assume this is PECL anyways since APC is)
I don't know how well any PECL will run against 7 tho
 
@Moak latter
 
> Take a look at doc.php.net to learn how to write php.net documentation
lol useless sentence is useless
 
@Rangad Yeh looks like it hasn't been 7ified yet, not sure what the status of this is /cc @JoeWatkins?
 
@DaveRandom He's in good company right now github.com/gophp7/gophp7-ext/wiki/extensions-catalog
 
user895378
1:48 PM
TBH local caching kind of seems like something web apps should move away from anyway. A distributed cache (like redis) makes more sense for performant, scalable applications.
 
@Machavity Goddamn github with their stupid hidden overflown content
 
@PeeHaa Click and drag the mouse to overcome it. But agree 100%
 
It also makes longer lines of coded impossible to read. Which is kinda bad for a code hosting platform...
 
@rdlowrey Yeh but sometimes that's overkill and you just want a quick-and-dirty solution with minimal messing about. I have a number of internal apps that are "just thrown together" and most of the time I want to deploy things like that ASAP, touching as few architecture components as necessary. TL;DR mostly true, but doesn't make things like APCu valueless
 
I count 13 PECL that are 7 compliant or in the process of being 7 compliant. Which is somewhere between laughable and dismal
 
user895378
1:51 PM
@DaveRandom good point.
 
I wonder what will become of PEAR as well
 
user895378
hopefully it will go away.
 
Hi
 
posted on July 08, 2015 by nlecointre

/* by Dolgsthrasir */

6
 
2:19 PM
php-src repo really doesn't get smaller :-/ already 240 MB :-/
 
:(
git rebase # flatten it :D
 
It cannot get smaller, because git?
:P
 
user895378
Yeah, version control systems are like the borg of disk space; ever expanding like the universe. Not enough php-src dark matter to result in the hypothetical Big Crunch.
 
Good morning
 
user895378
o/
 
2:29 PM
morniing
 
user895378
@ircmaxell Question ... I assume that because facebook uses hhvm internally that means all of their internal "php" code was failing to verify certs as well?
 
yup
 
user895378
WOW.
 
well, not all, they did use curl for some of it
 
2:32 PM
@rdlowrey yup, which is why it was bounty-worthy
 
user895378
Well, if they used crypto with any of the mysql extensions that's also affected. Not just http things.
 
user895378
Those bundled extensions all use the streams api for crypto
 
user895378
I understand that mistakes happen but that's a seriously big fucking deal. It merits swearing.
 
user895378
Like ... NSA happy land. Or, perhaps more damaging, trivially easy corporate espionage by competitors.
 
:-)
 
2:34 PM
I wonder if the openssl team has better opsec than I'm giving them credit for, or if ssl/s3_srvr.c is the high severity vuln?
 
user895378
@ScottArciszewski which one are you talking about? SSLv3 POODLE?
 
have I ever told you how much I don't trust openssl?
 
no
after reading this, I'm half-tempted to rm -rf the openssl_random_pseudo_bytes bit
 
leave it in, as a fallback
ssl3_get_client_key_exchange <-- HOW FUCKING LONG IS THAT FUNCTION?
 
can we trust it as a fallback?
 
user895378
2:38 PM
I don't have a problem with openssl_random_pseudo_bytes() specifically. If you have enough entropy a userspace RNG is adequate and having read Henson's breakdown of how it works it seems fine.
 
@ScottArciszewski lesser of evils IMHO
 
user895378
In the absence of a non-userspace RNG it is adequate IMO.
 
user895378
I've read that article many times, of course.
 
a good argument for leaving it in:
php on openbsd probably compiles with libressl
which means arc4random_buf() is used
 
2:40 PM
@ScottArciszewski ummmmmm
if I'm reading that correctly, whoever wrote that function needs to be fired, immediately
 
user895378
openssl_random_pseudo_bytes() specifically is fine as a fallback IMO. Why? Because it uses openssl's RAND_bytes() under the hood which will error out if there's not enough entropy to ensure an unpredictable byte sequence.
 
git blame?
@rdlowrey care to comment on github.com/paragonie/random_compat/issues/… ? :)
 
Is it safe to assume that expression %any_number_greater_that_zero% > 0 will always return 1 and not any other number >0 in C?
 
no
I'd test it first :)
 
user895378
@ScottArciszewski wait, I was wrong. php-src is still using RAND_pseudo_bytes() wtf
 
user895378
2:44 PM
I could've sworn that was changed.
 
heh
and if the PRNG Isn't seeded
it just returns bytes silently
 
user895378
Well good code should still error out if crypto_strong is true
 
I just went from not caring for OpenSSL to actively campaigning against it. Look at this function: https://github.com/openssl/openssl/blob/cb6e0ed17a61ae3711d385f517d61be2b4c33a55/ssl/s3_srvr.c#L2175 #whodoesthat
 
user895378
Sheesh ... this is a mess
 
user895378
Need to check in on the openssl version number when that was deprecated. We may be able to remove the RAND_pseudo_bytes() usage altogether.
 
2:46 PM
they RE-FUCKING use variables, for completely different usages, and call them things like i and n
that's ABSURD
 
user895378
Yeah the openssl code is a disaster to wade through. Not sure how you could modify things and feel good about the changes.
 
that's not a disaster, that's negligence
for a library that powers the security on 3/4 of the internet?
pathetic
downright pathetic
 
user895378
It's what happens when people who are good scientists but not good programmers start a project :)
 
user895378
What if we add openssl_random_bytes() to preserve BC for anyone using the pseudo bytes for non-cryptographically-secure uses and have it use RAND_bytes() under the hood? That way you wouldn't have to feel bad about falling back to it?
 
@rdlowrey no, it's what happens when we don't teach computer engineering in college, and only focus on the math
 
user895378
2:49 PM
@ircmaxell I'd say both, but you're definitely right.
 
a breaking API change wouldn't really make it in 5.6.11, for example
breaking API change => new function
 
user895378
@ScottArciszewski Oh, I'm only talking about php7 here
 
php7 -> random_bytes()
 
user895378
Though I guess you don't need a polyfill if you have php7 lol
 
user895378
2:50 PM
... the real problem is that ext/openssl was essentially unmaintained for 5-7 years
 
user895378
@ScottArciszewski Seems good enough to fallback to openssl_random_pseudo_bytes() and just internally verify that the resulting by-ref $crypto_strong boolean is true and error out if not.
 
hi folks - would anyone mind taking a look at this question real quick ? noob-level stuff:
0
Q: Where should I instantiate my cart with PHPCart in Laravel 5?

user4676723I'm making a simple shopping cart system using Laravel 5 and Vue.js. The user clicks the add to basket button and Vue sends an AJAX request to the cart controller. That part works fine. The documentation for PHPCart shows how to add an item to the cart: $cart = new Cart(); $cart->add([ 'id...

 
$crypto_strong will return true if the PRNG is not seeded
 
@rdlowrey have you looked into the feasibility of replacing OpenSSL with NSS (or something else) for the core stuff that depends on OpenSSL (stream crypto etc)?
 
but will return false if it fails to return any bytes
 
2:53 PM
Not that NSS or others are definitely better, but it would be good to have a choice
 
let's implement the pluggable crypto backend system we talked about
that way we can deprecate openssl and run away fast
 
^ basically this
 
user895378
What really sucks is that openssl is super integrated into lots of other things like streams and mysql extensions
 
I'll get started on a PHP-land toy implementation tonight
 
user895378
2:54 PM
It's not decoupled at all.
 
user895378
Ripping out openssl means we have to rewrite a lot of other code in completely unrelated extensions. It's a mess.
 
decoupling isn't or wasn't a thing in C land ...
also /me waves
 
user895378
Hi Joe :)
 
ahoy
 
2:55 PM
I was sedated this morning for dental work, I can move around now, which is nice ...
I probably couldn't normally tell what's up with that code, wanna explain ?
 
EAY
 
user895378
@ScottArciszewski @ircmaxell I do agree though that the only good solution is to completely rip out openssl and do a new backend-agnostic implementation from scratch.
 
well, I'm probably about to have a lot of free time on my hands :P
so I think I can get the ball rolling on that initiative
 
user895378
I really hate (note the italics) working on ext/openssl. It is not fun at all.
 
user895378
And a new extension means no BC complaints.
 
2:59 PM
you might do all that hard work, and have it be undone by incompetent package maintainers ...
 
what if a distro rolls out packages linked with backends with vulnerabilities in them ?
 
that was the idea I was kicking around/discussing with @ircmaxell in #php.security on freenode
 
user895378
Also, it may be worth looking at Jakub's crypto extension and working on that
 
well, I think I know what I'm going to talk about next week
I've been invited to speak to the UN about security. I was debating doing it or not, but after seeing this, I think I will...
 
3:01 PM
I was originally going to make this into a talk for php[world] but they said they had too many interesting talks to choose from
oh, nice
 
@ScottArciszewski gist.github.com/paragonie-scott/… s/public/private
 
@ircmaxell united nations ?
 
private?
oh
derp
 
@JoeWatkins yes
 
user895378
@ScottArciszewski he means it's a doc error -- private key
 
user895378
3:02 PM
yeah
 
@ircmaxell oh wow
 
user895378
@ScottArciszewski I'm fluent in @kelunik translations at this point ;)
 
@rdlowrey not always :P
 
thanks :)
 
user895378
3:03 PM
@kelunik lol it's true. We've had a few discussions go on for like an hour before we realize we're both saying the same thing.
 
user895378
I suspect the intent was noble when openssl was tightly integrated into streams ... after all, "let's make crypto a first-class citizen," sounds like a good idea on paper.
 
@ircmaxell all of my yes; openssl is a clunky mess.
 
3:20 PM
11:17 <boru> The two things which bother me most, though, are the length of the fuction (for no reason, presumably the cost of non-local jumps and function prologues/epilogues) and the inconsistent goto labels.
11:17 <boru> Both of which aren't really excusable, in this day and age.
11:18 <boru> Outside of that, it doesn't really strike me as poorly written C, for the most part.
this is why crypto people should not write code
 
user895378
Who doesn't love 4 levels of nested conditionals, anyway?
3
 
user895378
Also, things like goto f_err; mixed with goto err; in the same function are a nightmare.
 
I'm quite new with php. I would appreciate any help with my question at:
0
A: PHP - search using 2 concatenated fields

ChristianFThe easiest way to do this, is by splitting the string on the space. However, that introduces a bug if the person has more than one first- or surname. This means that in the cases where we have 3 or more elements in the result of the split, we'll have to add the middle elements to both matches; S...

 
@rdlowrey he does mention this bit :)
 
user895378
3:23 PM
@FlorianMargaine that's the kind of thing you hate yourself for if you revisit old code. But it's completely incomprehensible if you're reading someone else's code.
 
that's why you refactor it
 
if it ain't broke...
 
@ircmaxell have you had time to explore LibreSSL ?
 
@FlorianMargaine it's about to be :p
 
user895378
That's the thing. You don't know it's broken until it is. Good code is so explicitly readable that it's very hard to have hidden bugs.
 
3:25 PM
@tereško I looked at it briefly
@FlorianMargaine broken window theory, which has been proven false
 
so, it might be as terrible as the openssl
 
@rdlowrey yeah, openssl is definitely not the kind of codebase where you can say this.
 
LibreSSL is an open-source implementation of the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols. It was forked from the OpenSSL cryptographic software library in April 2014 as a response by OpenBSD developers to the Heartbleed security vulnerability in OpenSSL, with the aim of refactoring the OpenSSL code so as to provide a more secure implementation. LibreSSL was forked from the OpenSSL library starting with the 1.0.1g branch and will follow the security guidelines used elsewhere in the OpenBSD project. == History == After the Heartbleed bug in OpenSSL, the OpenBSD team...
chech the vuln table ;)
 
user895378
@ircmaxell That's probably the single most useful takeaway from Moxie's "defeating ssl" video IMO. The part where he shows the deeply nested code and is like, "you KNOW there's a bug in here"
 
user895378
That was the first time I made the connection between secure code and good design.
 
3:28 PM
> Affected code is not present
hehe
 
what we need isn't a fork
what we need is a rewrite, using good standard practices and full unit testing
 
@FlorianMargaine They ripped out a good 50% of openssl's codebase and refused to support legacy systems. Which is a nice idea. But it's still not going to have people begging to contribute, or code reviews on contributions. Or decent tests.
 
too many projects, not nearly enough time to do them in
Tighten up your security. Decrypt the message & answer via this form to win a Security Key: http://goo.gl/fofEGI http://t.co/CnN9EowPKA
lol
 
@rdlowrey It's weird how the 8.3 mentality spread to places where there was never any such restriction... at least that's what I assume is the cause of such things, I can't think of any other reason for it
 
3:38 PM
"Summer’s a discouraging time to work — You don’t feel death coming on the way it does in the fall" - Ernest Hemingway
 
@DaveRandom 8.3?
 
@rdlowrey is there something you want to tell us?
 
user895378
@ircmaxell lol, no, I just have noticed that I always have a hard time being productive in june/july
 
user895378
Too many other good options
 
3:39 PM
:-)
 
@DaveRandom ah, it's DOS. UNIX had a 6-chars limit iirc, hence names like umount.
 
Oh right, I'd never really considered it but there are some weird names for some unix tools. I've always wondered where "cat" came from, for example.
 
@DaveRandom concatenate
 
Although there is another advantage for things like that, it's good to have short names for things you type a lot
 
3:41 PM
@DaveRandom for things like cat, yeah. For things like umount...
 
@FlorianMargaine Oh, true. I almost never us it for that but I suppose that's what it's originally for.
 
@DaveRandom heh. I've used it to create multi-files tar archives
 
...or you could just sane storage media, but sure, whatever floats your boat :-P
 
@DaveRandom I'm trying to remember what I used it for
can't :/
 
user895378
Hate to be prophet of doom but China's having serious economic issues right now. If Greece sinks the Euro zone and China bottoms out at the same time we might all be in for a bad time over the next few years.
 
3:46 PM
Maybe you were kicking old-school and storing things on a set of ZIP disks or something
 
@DaveRandom no, I think it was because of some FAT limitation
(and every usb key is on FAT)
 
@rdlowrey I'm confident that Greece will be evicted before they're allowed to take everyone else down with them, although I hope that doesn't happen either because it still won't be awesome for everyone else
 
user895378
@DaveRandom I was reading about how one of the things being discussed was a blanket 30% haircut on all deposits in greek banks greater than 8,000 euros. I would be sooooo upset if the government came to me and was just like, "oh BTW we're taking 30% of your money."
 
user895378
It's all a mess.
 
3:51 PM
@rdlowrey It's going to be worse than that, there's almost certainly going to be a forced conversion of money from Euro to a new Drachma...
 
user895378
dang
 
@rdlowrey *except if you're rich or working for the government
 
They should just adopt the Triganic Pu instead
 
user895378
@DaveRandom Or the PHP?
 
> The currency code for Pesos is PHP, and the currency symbol is ₱.
 
user895378
3:53 PM
PHP should accept an alternate variable initializer, ₱, to replace $
 
I guess we should call PHP with ₱ now
 
@rdlowrey Yeh, that's what we need, an economy based on PHP, where everything is computed with floating point arithmetic and the entire economy fatals occasionally because someone tries to cash a hastily written illegible cheque.
 
user895378
In case you were wondering: yes, that currency abbreviation makes filtering the twitter data hose for php programming tweets more difficult than it should be.
 
user895378
@DaveRandom That's why it's perfect for Greece lol!
 
Good morning.
 
3:55 PM
@rdlowrey well, you only need a couple of lines to change
 
user895378
@LeviMorrison o/
 
@DaveRandom reminds me of bitcoin
 
@rdlowrey How's it going, pal?
I've been really busy and haven't chatted with you for a while.
 
user895378
@LeviMorrison Fine, thanks. I've been away from the computer much of the summer so far, so you probably haven't missed much. How's baby #2?
 
Doing great. She's a little cutie!
She loves to be held and cuddled, which I like.
My wife gets sick of it sometimes because she wants to be held literally all day.
:)
 
3:58 PM
is she sleeping all night yet?
 
Nope. She's just 1 month old so she has a little while before she will sleep through the night.
 
don't discourage me. :(
although baby's done 5 hours straight for a couple of nights, felt good.
 
one of ours done 8 hours at a time, which sometimes meant all night, within about a fortnight ...
however, the other just cried for the first 6 months ... all the time ... non-stop ...
 
@FlorianMargaine Hopefully you'll adjust to it like I have.
 
@LeviMorrison well, I had never slept on my sofa before... ;-)
a nap sounds like a great idea right now.
 
4:03 PM
 
I just wrote an entire class full of set_error_handler() and restore_error_handler() -.-
file manipulation functions are a mess.
 
@Ocramius are you sure you have no race condition? :-)
 
@FlorianMargaine Race condition
 
@FlorianMargaine I take naps on my lunch break sometimes.
I have a yoga mat, pillow and light blanket.
^^
 
4:16 PM
@FlorianMargaine I have loads of them there, that's why I brutally evict files multiple times when I meet any
 
@DaveRandom I don't see any race :P
 
@DaveRandom Want need!
 
4:35 PM
Morning.
 
4:47 PM
I'm surprised no one added the spaceship to this...
0
A: Reference - What does this symbol mean in PHP?

Sherif<=> Spaceship Operator Added in PHP 7 The spaceship operator <=> is the latest comparison operator added in PHP 7. It is a non-associative binary operator with the same precedence as equality operators (==, !=, ===, !==). This operator allows for simpler three-way comparison between left-hand a...

One of the highest upvoted PHP questions on SO. You're slipping guys...
 
@Sherif Honestly, I've always implemented that as return $a - $b;
 
@Sherif hrhrhr :D
@Leri same here ^^. lol. did the edit.
 
@Leri The problem with that though is what happens if $a = -1 and $b = 2?
What's worse is you get really bitten on that when $a or $b are floats and not integers.
See the warning I put in the manual for more details.
 
@Sherif Negative value will be returned which is expected value, isn't it? And if you compare floats you're doing something wrong anyways.
 
What's wrong with comparing floats?
 
4:55 PM
@Sherif you have to take precision into account when you do so.
 
All values worth sorting are integers in your world?
Precision has nothing to do with what I'm talking about.
> Caution
Returning non-integer values from the comparison function, such as float, will result in an internal cast to integer of the callback's return value. So values such as 0.99 and 0.1 will both be cast to an integer value of 0, which will compare such values as equal.
 
@Sherif Nope, you just need to take precision into account, actually correct one to the desired one before comparison.
 
Read above ^
Precision has nothing to do with this.
 
return 100 * ($a - $b);
take precision into account. as written.
 
@Sherif read my message above, you need to correct to the desired one. @hakre has already written what I meant.
 
4:58 PM
@hakre Because every value in the array you are sorting is expected to be of the same order?
 
@Sherif having those meant to be equal can be intentional. just in case that's the obvious part missing here.
 
What if $a = 0.01 and $b = 0.002
I think you're missing the point entirely and focusing on trying to justify why $a - $b works for you.
 

« first day (1726 days earlier)      last day (3225 days later) »