« first day (845 days earlier)      last day (4103 days later) » 

10:00 AM
Poor microsoft, oh how the mighty have fallen.
 
@ShyamK What I want is AD & Exchange -> Linux, then bye bye Windows completely.
 
@DaveRandom amen
 
Actually that is a fair point, Outlook for Linux would definitely be nice.
 
Hey Peeps, I could use some help with mysql syntax/logic.
I have two tables, from one we get the item info, the other we get a count of things related to it, lets say comments.
$query = "SELECT i.title, i.item_id, count(c.comment_id) as related_number FROM item_table i INNER JOIN comments c ON i.item_id = c.item_id WHERE i.item_id = 5";

This is a simplified version of the query I'm writing. I just want to understand, how do I get count not to display 0 and item info "NULL" when the item is not found. I need it to count ONLY if there is a product. I thought inner join would have taken care
 
@DaveRandom Evolution?
 
10:01 AM
^ what uncle G said
 
@Darius You want conditionals in MySQL basically
@Darius ria-coder.com/blog/using-conditional-statements-with-mysql was a quick google, you can continue googling "MySQL Conditionals" yourself ;)
 
Mysql conditionals better than php conditionals?
 
@DaveRandom OWA would be an option, too
 
I will look into it, thank you.
 
10:02 AM
@Darius Well yeah, because doing it in PHP would mean you're pulling back more data than you want right?
 
correct. Thank you!
 
@DaveRandom When I use a url loadHTMLFile returns false
 
@Gordon Exchange connectivity is shocking, same for Entourage and every other email client ever made apart from Outlook. I'm not saying Exchange is perfect, but in SMBs it is exceptionally good compared to every other option.
@Gordon True, but it's still very tied down to IE :-X
 
@DaveRandom yes, it is.
 
@DaveRandom You not like good old thunderbird?
 
10:03 AM
@DaveRandom you could also try Outlook on Wine or move all your mail needs to Google.
 
@Gordon Granted, but that's not really getting rid of Windows, I'd much rather have a version of Outlook specifically designed to run on *nix (and not stupid Apple pretend *nix).
@Gordon Mmmm, Google definitely an option though. I used to be very uncomfortable with the idea of a 100% hosted solution but these days I think they are probably reliable enough - I got burned a few times a few years ago, really turned me off. Hosted telephony services are still nowhere near business class though, IMO. Not matter who you pick as a supplier.
@Jimbo No. Just... no.
 
PHPNoob's profile: Dislikes: Fatal Errors, PDO, OOP, Loops, Arrays, all the super globals, and tereško
 
@DaveRandom the main reason against google is privacy IMO
but hey, I got all Google Nexus devices so what do I care about privacy
 
Privacy is a myth.
 
Yes, that is something I worry about. Google have managed to get a public image of a kind of BDFL for the internet, but I do worry that Larry and Sergei are sitting in a lair in a volcano somewhere, plotting the demise of mankind.
 
10:11 AM
@NickFury yeah it is
 
@DaveRandom I'd wish they instead plot how to improve the multi-account crap.
 
@Jimbo teresko? lol... he just like an old uncle... very harsh... he means well
 
@mr.freshwater OK well you should get an error as well, check your server error logs and/or put these two lines at the top of your script: error_reporting(~0); ini_set('display_errors', 1);
 
OLD UNCLE you hear that tereško :P
 
10:13 AM
@NickFury Good guy @Dave is the only person I want to share my girlfriend with :)
 
@DaveRandom ~0 because -1 is more difficult? lol
 
@Jack The current mess is all their evil doing. It's the first step on the road to international insanity. They've figured out the secret sauce for how to manage vast amounts of data efficiently, now they are sending us insane with data overload, one password at a time...
 
Should put MVC === MVP on his tombstone for an eternal trolling
 
@Jack Force of habit. Although to be fair it does more accurately describe what you are doing, setting every flag in a bit field.
@PeeHaa :-D
 
Been tinkering with Sylex over the past few days ... hey, it's nice actually :)
 
10:16 AM
@PeeHaa bowchickawowwow Peehaa's here to lay down some xpath. bowchickawowwow so you two are attributes ?
 
:P
 
lol
@Jack (Googles Sylex) Yeh I've heard of that and know what it is and have opinions about it and everything
runs away
 
@Jimbo I wrote this as a conditional statement
"if(i.item_id > 0, count(c.comment_id), NULL) AS `count_comments`"

Now it works somewhat, it knows when to display null and not count, but it still returns a row with all NULL values instead of saying not found. How do I get it to say no rows found instead of returning a row with all NULL values? Did I get it wrong?
 
@DaveRandom It solves a few problems I had before, such as how configuration is managed.
And my controllers have never looked cleaner tbh lol
The only hard dependency is the HttpFoundation classes for Request and Response.
 
@Darius This may help: dev.mysql.com/doc/refman/5.0/en/working-with-null.html You can check in MySQL if a value is null :)
 
10:20 AM
Hi folks
@DaveRandom @Jack Sup!
 
@DaveRandom codepad.org/VIxll6vD - partial implementation.
Had to use some persuasion so that I could use my own template and translation classes, but got that figured out as well heh
 
Oh... that girlfriend
 
@Jack Mmm, looks interesting, going to take a proper look later
 
@Jimbo Got it, so I'll add a WHERE i.item_id IS NOT NULL and that should take care of it.
 
@Korhan Yo
 
10:24 AM
There's some work involved to really decouple the controller from the Sylex system itself, but worth it imho. @DaveRandom
 
@Darius Yep, that's what I use to check for null values MySQL-side
 
Thank you very much.
 
No worries :) It's cool to know that stuff so when it comes to MySQL in the future, you'll have a larger mental toolset to get what you want!
 
@ShyamK lol
 
All these MySQL troubles simply disappear once you switch to Array backed storage =D
 
10:29 AM
@Jack mongoDB?
 
@ShyamK Heavens no, that stuff's way too complicated for mere mortals =p
 
@Jack's brain is not web scale.
 
Being a ZEND certified does anything ?
 
It makes you super awesome cool.
 
@DaveRandom Thanks
'sup?
 
10:35 AM
See? Who wouldn't want a grinning mug like that?
 
@DaveRandom Jack's brain is a bit fried, for that extra crunch.
 
@DaveRandom - Really ?
 
Zend certification is definitely web scale and enterprise ready.
 
@Jack - I am thinking to start reading for that then
 
Reading will get you nowhere.
 
10:45 AM
I always wanted nowhere. I might start reading.
 
@webarto I wouldn't say nowh.... too late, now look at what you've done.
 
Won't get you anywhere?
Damn, you guys are fried.
 
:D
 
That's the same thing ... "Simply reading won't get you where you want to be."
Or ... "One does not simply read to get somewhere"
 
So the best way to read for the ZC is to... learn the whole PHP manual off by heart...?
 
10:47 AM
@webarto - You are certified...so you can suggest
 
@Jimbo blah. last time I bug you. Maybe I'm using the IS NULL in the wrong place? I'm still getting all rows with NULL. Here is a sample query, let me know if you want me to create the insert query to test.

$query = "SELECT i.title, i.item_id, if(i.item_id IS NOT NULL, count(c.comment_id), NULL) AS `count_comments` FROM item_table i INNER JOIN comments c ON i.item_id = c.item_id WHERE i.item_id = 5 AND i.item_id IS NOT NULL";

It knows when to count it, it knows when to put null. Issue is, when I use COUNT or SUM in the query, it returns a row, when I use lets say a value 0 or 1 or 2, it w
 
@Darius I'm not sure, have you tried putting the NULL check first?
 
@Jack Oy, easy there mate, haven't had coffee yet... you have CSS overflow :P i.imgur.com/C2AFUvv.png
 
@Jack to get somewhere... one may use a map too...
 
0
Q: Php high memory usage

mucieWe have an old facebook app, running smoothly written in native php. This month we decided to rewrite it in zend-framework 2. Yesterday, after switching to new app it crashed our server with lots of out of memory errors. So we turned back to old app. I installed xdebug to profile the app. Using...

I knew it, ZF is evil!
@webarto Wud?! Let me kick the dev :)
 
10:49 AM
@Jimbo at which point is "first" considered? Should I run the regular query first to get results, THEN do another IF ? Like get product, get the rows, and then say IF? as if a php function?

Clarification, should it be two queries then somehow? or is one query correct.
 
@Darius I'm not sure what the best way forward is but, what about another IF within the query, before the first one, that first checks that there a no NULLS before continuing
So an IF within an IF, if you will
 
hmm
 
@DaveRandom Will you take the exam?
 
IF( fields arent null then ( IF ( do your stuff ) ) )
 
@webarto As soon as I can afford it, still recovering from Christmas
 
10:53 AM
Trying to wrap my brain around it, give me a few.
 
@DaveRandom Ok, chances are I won't use mine and I'll give it to you... If I use it per chance, I can get you one for $120.
 
@Darius One of the first few results from a Google search "MySQL Nested IF" : komlenic.com/254/mysql-nested-if-in-select-queries
 
This is pissing me off so much lol, I've done so many inner joins and left joins and never had this issue before... For sure an inner join should've been enough to tell it not to count...
 
I'd continue searching from there ;)
 
Kk. will do thank you.
 
10:55 AM
@webarto I thought you had already done it? Why do you have another one?
 
@DaveRandom For Zend Framework 1, but vouchers are the same.
 
@webarto Nah, it's the surrounding <div> that has a 234px left margin lol
 
Ahh! That page explains it a bit, will give it a shot. Thank you "nested" . so SELECT IF(query, blah,blah) order by etc.
 
@webarto You waiting for a ZF2 exam?
 
@webarto margin should be gone and the anchor should just float to right instead of left .. it's amazing that it works on chrome
 
10:57 AM
@DaveRandom Nay, I don't think I'll pass at the moment...
@Jack Sometimes when I do it wrong it shows up right :) Cool.
 
@webarto exactly :)
 
@Jimbo got it! Thank you :D
 
@webarto Well if you're not going to use it let me know, I'll give you whatever you paid for it, no point in letting it go to waste. When does it expire?
 
Certification - Zend PHP Certification Voucher Jul 05, 2013 Jul 05, 2013
 
@webarto kk, well let me know. Presumably that expiry date is when you have to book a date by, rather than when you have to actually sit the exam?
 
11:04 AM
@DaveRandom Nah, you have kid(s) :)
@DaveRandom Yes, and you have to book it earlier, but I don't know how much timespan is allowed, I took it 2 weeks later (after booking).
 
@DaveRandom you'll pass without a grain of sweat, ask @Gordon.
@RajeevK It doesn't mean anything if you don't know how to do things right... everyone can pass it just like any other exam...
 
@webarto huh? what?
 
@Gordon ZCE exam, @DaveRandom wants to take it.
 
@webarto - I really don't know how to do things in PHP...and thats why...
 
11:10 AM
@webarto don't underestimate it.
 
@Gordon I'm not, if I passed it @DaveRandom can for sure. That way I'm underestimating myself :)
 
there is a number of questions in it that dont test your skill but rather your ability to memorize, like which functions does exist: stream_socket_open or socket_stream_open or stream_open_socket
 
@Gordon It's none of them :-P
 
or which signature is right: in_array($haystack, $needle) or in_array($needle, $haystack)
 
@Gordon - You mean by memorizing stuff...we can be sure for some question to attempt
 
11:13 AM
@Gordon Second one. I really wish the string and array functions had the same signature pattern, I've drilled it into myself now (for the ones I use a lot) but seriously, wtf. That's essentially examining people as to whether they understand just how poorly some elements of PHP are designed.
 
or silly code questions like
function fn ($a) {
    $b = $c = 1;
    $c += $a;
    return $b;
}


fn(10); // returns?
 
lol
 
I celebrated for 2 days... I expect an invitation from you @DaveRandom :P
 
Still, I guess reading sh*t code is an essential part of being a programmer.
 
See, that silly question would've got an amateur like me. I would expect += to return an error because i've never used it lol. I only know of .=
 
11:15 AM
@Gordon Can you do $b = $c = ?
Also, why would you do it?
 
@Jimbo can you?
 
@Darius It returns 1, look at the variables being operated on, ignore the operations.
 
@Gordon I don't know, I asked you!
 
LOL
 
Haha, doh! There we go! lol.
 
user652649
@Gordon parameters order in php is very hateful... sometimes i have to check the manual
 
@wes I always have manual opened.
 
@wes - I check all the time
 
user652649
well, i check the manual even for in_array for example
 
3am... the religious commercials begin..
 
11:18 AM
@Jimbo is that the only thing you find odd about the code snippet?
 
@Gordon What, apart from the fact the function is called fn?
 
@Jimbo Yes you can, I do it quite a lot, for ex when I have a loop that refactors arrays and needs a temp array in the process, like $result = $temp = []; creates two arrays. Be careful though, it doesn't do what you might think with long chains of references.
 
@Jimbo what do you think it returns?
 
@Gordon Just to be clear, I wasn't saying everyone per se, but any of the regulars from this room.
 
11:19 AM
@Gordon Okay, so you pass in 10. $c is set to 1, then $b is set to $c, so both $b and $c are now 1. Then, $c = 11; Then $b is returned as 1.
 
Man, some of the code that powers bits of PHP.net really, really sucks.
I just found an ereg()
 
@Jimbo right, completely pointless
 
@DaveRandom s/some/almost all ... it's legacy though... it's 10 yo...
 
@Gordon Yep because... well you don't return anything to do with the number passed in right
 
11:22 AM
@DaveRandom We can rewrite the god damn thing... it's not a one man job...
 
@webarto Well quite. I'll come back to you in a couple of days regarding that actually...
 
When I see a long list of things like that: $a = $b = $c = 1;, I always imagine what you do with functions - you always perform the most inner first (in this case it's the most right)
 
@Jimbo as for why one would do $b = $c, well, simply because two vars share the same initial value, like $isThis = $isThat = false and then the remaining code will use these flags somehow
 
implode('',explode('|','HER|RO'));
@Gordon Ah I get it, so when you instantiate some variables with the same value you can do it for simplicity
 
$stdErr = $stdIn = $stdOut = NULL
 
11:26 AM
foreach($var as &$v) { $v = NULL; }
 
@webarto I also remember there was a couple of questions that were webdevelopment related, but not PHP related. Like questions about HTTP or which encryption methods are symmetric and which asymmetric
 
Yeah I prefer just multiple =
 
$var = array() would be cleaner ;) (unless it's an object or something, in which you wouldn't need the reference )
 
@Gordon $bitwiseFlags++; :-P
 
@Gordon Yes, indeed, it was more of a general tests, which is good IMHO, I got about 5 SQL questions too.
Too bad there wasn't jQuery...
 
11:29 AM
hah, I think the headache is finally wearing off
 
@Gordon :D
vimeo.com/59023055 boss sent me this... tough life...
 
guys. should the cvbacklog also scrape delv-pls tags?
 
Since Dave showed me array_walk() being better than foreach(), I've considered learning how to use it and just using array_walk() insteead
Even though it only makes a difference with large arrays, I might as well just use it with everything (so as to encompass both small and large)
 
@Jimbo that @DaveRandom works in mysterious ways
 
@Gordon Btw, awesome code, if I haven't said that already.
 
11:32 AM
I said no such thing
 
@webarto thanks but it's really just something I hacked together quickly. It doesnt even have tests and the folder layout is very suboptimal :) dont take it as a reference for good code.
 
@Jimbo I said it can be better in some circumstances, it's not better all the time.
 
construct vs function
 
@DaveRandom YRemember when I was trying to iterate a massive array, and you and ircmaxwell explained how array_walk() doesn't create a copy of the array
Hmm okay, so when is it not better? As in, less than equal to
 
Yes but that was because you were using references
 
11:34 AM
@Jimbo yay for Golden Hammers!
 
:D
I'm starting to like Zend Framework, am I going mad?
 
@webarto yes!
 
@DaveRandom did you ever find out why (function() {}()) is more valid than (function() {})() in JS?
@Gordon yes!
 
@Jimbo the walk/map functions are very good for working with refs and for when the body of the loop might be dynamic (because you can pass a different callback in). But foreach is usually more transparent in terms of code clarity. For ex if you are just looping over something and outputting values from it, use foreach.
 
@webarto Did you just approach something that made you go "oh, I like this now!"
 
11:37 AM
@Gordon at the minimum the list for the next release is: github.com/cv-pls/cv-pls/issues/63
 
@DaveRandom Okay, so anything more complex than a simple loop might merit walk/map for micro-optimisations then
 
To go really wild we want at least this for some future release
 
@PeeHaa I meant the PHP backlog ;)
 
@PeeHaa Please come to your senses.
 
@webarto never!
 
11:39 AM
@PeeHaa One beer you said :P
 
@Gordon WHat is the php backlog?
@webarto No I did not. quick beer was what I said :D
 
@PeeHaa cvbacklog.gordon-oheim.biz Feel ashamed, feel very ashamed.
 
@PeeHaa the cvbacklog as opposed the cvbacklog plugin
 
@Gordon that's what those issues are about :)
 
@PeeHaa why would the backlog need an API key … aaaaaah, you mean for accessing the SE API?
 
11:41 AM
Correct :D
 
@PeeHaa No, but I have a suspicion it's just Crockford forcing his stylistic preferences on the world (like so many things about JSLint). However, it does make more sense to me now I've been doing it for a while, because what you are doing is declaring a function and calling it in a single expression, and if you put the call parens outside then you are declaring a function in an expression, then calling it, and since the function doesn't exist afterwards the former makes more sense to me. YMMV.
 
Ok, guys, slow down, you're hurting my brain.
 
ok, I got that wrong then. I thought you meant it should provide API keys
 
@Gordon neh ;)
@DaveRandom Sounds legit
 
@Jimbo Nope, I've rewritten what I don't like. Only thing left is Doctrine1 which is sloooooooow.
 
11:42 AM
hey guys
 
@Demorus Hey!
 
any idea why this looks blurry in chrome? rolfvohs.com/sponsors.php
: / im really getting nightmares xD.
 
Define "blurry". Also define "this"
 
oh. Well you see the images on the site? Chris hein etc. Should look blurry on chrome but clean in IE and firefox
when looked at offline it seems fine though.
 
@Jimbo Not necessarily, if you are just reading data from the subject and you need any external variables then foreach is probably better, mostly because PHP closures are a little sucky and you have to explicitly declare the variables that are closed over instead of it inheriting the parent scope :-X
 
11:46 AM
@Demorus Ah now I see what you mean. Looks a bit like some crappy JS code
 
ya indeed although everything is run through CSS3 and html5!
looks all fine in the other browsers
 
In that case I would try to find out exactly what transition is causing it and try to find a workaround
 
I suspect it is the transform thats causing it
 
@Demorus It will still have some issues (this really shouldn't surprise one)
Let me see Chrome canary build whether it is "fixed"
 
I want.
 
11:54 AM
@webarto looks cool ..
 
Okay, maybe not as good as the SNES...
 
Honestly if it looks blurry in opera and safari too then ill remove transform for webkit
 
user652649
@webarto i wonder how much lead is in that 25 years old japanese plastic
 
^^ that's where it's at. The game is still playable as well.
 
Anonymous
12:12 PM
php rocks and sucks
 
Can anyone tell me whether ereg('@', $str) does something special, or is it just equivalent to strpos($str, '@') !== FALSE
 
Anonymous
why not compare ereg VS strpos instead, of being a help vampire
 
@DaveRandom Any help 3v4l.org/sZRLf/vld#tabs ?
 
@DaveRandom hi
 
@DaveRandom It returns length of matched string opposed to position?
 
12:18 PM
@webarto Not really, only show PHP opcodes, ereg() is a bit of a black box. I know bugger all about POSIX regex, every time I try and use one on the cmd line I always screw it up, I really should learn it I guess, although I wish that POSIX would just use Perl-esque expressions instead.
 
@DaveRandom I celebrated when Notepad++ used PCRE in version 6+... So I suck too...
 
What I really meant was "is @ on it's own some kind of special token in POSIX regex", or is that line basically just seeing if a given string contains an @
EditPadPro ftw where regex is concerned, IMO
Meh, I'll just replace it with a strpos() and see if it breaks anything.
 
Your best bet :P It's punctuation character in [:punct:]
 
@DaveRandom might have a special meaning: boost.org/doc/libs/1_44_0/libs/regex/doc/html/boost_regex/…
But I cannot find any reference as to what it does, so maybe it's just a bad example
@Demorus Same issue in latest chrome build btw
 
@PeeHaa Mmhmm, I read that and that's what made me question it. I think that's just saying "any escape sequence that's not a valid escape sequence will drop the backslash", but I'm not 100% certain.
 
12:28 PM
> Any other escape sequence matches the character that is escaped
 
> The POSIX standard defines no escape sequences for POSIX-Extended regular expressions, except that [...] the effect of any ordinary character being preceded by an escape is undefined.
 
After re-reading that a couple of times I suspect you are correct
 
F*ck it, strpos() it is.
 
:D
 
How do you guys like the new duplicate selection?
 
12:30 PM
It's much nicer, we need to have a discussion about how the dupes helper will work and look/feel to integrate with it
Do we know if that's the final result or will there be further changes?
 
@DaveRandom wut? nicer?>?
You suck
From now on all design decisions for the plugin go through me first! ;)
Ow wait I suck at design
 
Not as hard as you :-P
 
loool
 
@PeeHaa Not as badly as me. Making things do shit is my forte, making them look nice is definitely not.
 
What about (if possible) change the box with possible dupes with the dupes helper list?
with for example a tab to go back to the "official SO list"
 
12:35 PM
So just change the items in the list? Works for me, fairly easy to implement and doesn't require any designing, we can just inherit the native styles.
 
Wow. jslint guides suck:
> Expected exactly one space between 'function' and '('.
@DaveRandom Yup. And perhaps the most relevant on top (although this may require some serious guessing algo)
 
Yeh, I always tolerate "messy" whitespace. I wish it had a way to define your own whitespace standards, that would make that element of it quite useful
@PeeHaa Yeh, I highly doubt we can beat SE at that game.
 
Yep :)
 
Get a life.
:P
 
I have a dishwasher. Does that count?
 
12:38 PM
:D
Markdown helper could be useful (to me :P)
 
@webarto ...that does what?
 
  *italic* or _italic_
        **bold** or __bold__
        `code`
        ---strikeout---
        [link text](example.com "optional title")
:P
I'll try to do that for practice, plugins are cool.
 
word
 
Morning Sunshine(PHP).
 
My flight doesn't leave for 7 hours... (exactly actually)
 
12:40 PM
@DaveRandom JS confirms your suspicion
in JavaScript, 1 min ago, by Amaan Cheval
Because Crockford likes enforcing his style.
 
@ircmaxell How long does it take?
 
@ircmaxell STOP! beer time
 
3 hours
 
Awesome.
 
@PeeHaa nah, I have something important to do this morning first
 
12:42 PM
@webarto Oh you just mean like a little static popup reference? That should be easy enough, write it as a user script, I'm working on a little something that should make it dead simple to convert it to a full blown browser plugin for Chrome and FF (although whether it would really be necessary for something like that I don't know, but it does make auto-update possible)
 
make a WYSIWYG editor for chat.
 
Word. ^ @DaveRandom
 
@ircmaxell May God have mercy upon your soul.
 
why?
 
@ircmaxell a WYSIWYG editor for chat? I shudder with memories
 
12:46 PM
why? We have one in the question/answer section
 
@ircmaxell That's not exactly WYSIWYG
 
so?
 
It's a markdown editor with a preview area, there's a difference.
 
hey guys is it better for() or foreach() loop in general?
 
Ok, your point?
14
A: Performance of FOR vs FOREACH in PHP

ircmaxellMy personal opinion is to use what makes sense in the context. Personally I almost never use for for array traversal. I use it for other types of iteration, but foreach is just too easy... The time difference is going to be minimal in most cases. The big thing to watch for is: for ($i = 0; $...

 
12:48 PM
That shouldn't be too hard anyway. The only thing difficult about it is accounting for the places where the chat markdown fails. Apart from anything else you can probably just pinch the codez from the main site, since it's done client-side.
 
good point @ircmaxell what you think personally?
 
@ircmaxell Where'd you pull that out of so quickly? :o
 
@Badaboooooom i know waht you will write it here
 
> My personal opinion is to use what makes sense in the context
It's the first sentence!
 
it says what I think personally (in those exact words) in the first sentance
 
12:48 PM
)) @Abyss
 
@MadaraUchiha I got an upvote on it today, so it was at the top of my rep page
 
@ircmaxell lol
sorry didn't checked who answered )
 
That beautiful mugshot kinda gives it away
@ircmaxell Is that photo from a wedding or sth? Or do you just like to dress up for work? :-P
 
@DaveRandom yes
 
@ircmaxell array_map() will have better performance than for and foreach, right?
 
12:51 PM
It's a Jersey thing.
 
Something about it uses a C for loop, while those two use a PHP one.
 
guys better echo "<div>"; in html
or
 
@MadaraUchiha again, depends on what you're doing, but in general, no, array_map will perform worse than foreach...
 
oh damn bad example ) @Abyss
 
@MadaraUchiha I suspect the function call(s) would blow that loop optimisation away
 
12:51 PM
the only time array_map will be faster is if you're only calling a single function inside the loop, and tracking its return...
 
foreach ($foo as $v) { $ret[] = something($v); } will be faster as $ret = array_map('something', $foo);
 
but foreach ($foo as $v) {} will be much faster than array_map(function() {}, $foo);
 
Not sure where I've read that one...
 
12:53 PM
as foreach ($foo as $v) { echo $v; } will be faster than array_map(function($v) { echo $v; }, $foo);
 
guys assuming i'm ona html view do you think is better to write this:
<?php foreach($a as $row){ ?>
<div>
<?php echo $row->u; ?>
</div>
<?php } ?>
or this:
 
On a somewhat related note: I hate that unicorn "song"
 
<?php
foreach($a as $row){
echo "<div>".$row->u."</div>";
}
?>
 
and it's not because the loop is happening in C
 
@Abyss check above ^ ) my question
 
12:55 PM
it's because the function call dispatch is happening in C, which means you can avoid a bunch of opcodes that would need to be executed to do the function call...
(initFCall, send for each parameter, doFCall), so you're saving at least 2, and possibly many opcodes...
for each iteration in the array
Now, something like array_sum or max will be faster because the loop is happening in C, but that's because all computation is happening in C, not the "loop" (so allocation, etc)...
 
@ircmaxell what you think about my last question sorry?
@NullPointer u too pls
:P
 
I don't
 
comeeee on ))
i have a trouble with @Abyss first example is what i use second is what he uses )
we need your opinion man :)
 
@Badaboooooom I've done this for your code in mine:
 
... ? :)
 
12:59 PM
<?php foreach($a as $row) { ?>
<div><?=$row->u?></div>
<?php }?>

Although people will *hate* that, it's preference :P
 
i'm sure you @ircmaxell use the first example sintax :P
 
No, I use neither
 
@Jimbo ok thanks!!
@ircmaxell you spiderman right? )) joking
 

« first day (845 days earlier)      last day (4103 days later) »