« first day (956 days earlier)      last day (4008 days later) » 

10:00 PM
jo @JoeWatkins
 
Anonymous
Yea, he does answer noob questions, like me. And he has insomnia, so it is really not a fair competition on my part
 
What's wrong with answering noob questions?
 
@phpNoOb insomnia ? maybe he was just joking ...
@AshwinMukhija duplicates, check the manual questions should be closed
 
I heard most n00bs have aids !!
 
Anonymous
@AshwinMukhija I just rather to be a bounty-hunter
 
Anonymous
10:01 PM
@JoeWatkins which "aids" are we talking about here?
 
the crippling, deadly, eventually terminal one ...
 
@JoeWatkins I'm HIV positive about that
 
Anonymous
lol @PeeHaa埽
 
@PeeHaa埽 Can't tell if serial or trolling
 
I think he's super serial
 
10:05 PM
Please people. Indent your code or GTFO stackoverflow.com/questions/16824594/…
 
Mixed tabs and spaces fail
2 days ago, by HamZa DzCyberDeV
user image
2
 
What I have been wondering... who is that third guy?
 
haha
 
he's name is GIT
or DIFF
 
or one of my colleagues
 
10:08 PM
lol
 
lolz
guys honestly, do you use SQL procedures or triggers ?
 
I occasionally use triggers
 
@HamZa I try to keep the business logic in mah codez most of the times
 
Procedures rarely but sometimes, triggers never
 
Hmmm ok
 
10:10 PM
how to make first array into second array pastebin.com/raw.php?i=CJRFsh44
 
I would use triggers if it were easier to fire them back into PHP, but obviously there are numerous reasons why that's not really practical most of the time
Holy crap, an actual use case for array_column()
 
@DaveRandom hahahahaha
 
array map?
 
@DaveRandom yeh without it it would have be freaking impossibru...
:-)
 
@SteveRobbins You just need to loop the array. Whether you do that with for, foreach, array_map(), array_walk(), whatever, it's all pretty much the same logic you need. Loop the child arrays and reduce them to just the value you want.
 
10:13 PM
@DaveRandom It's a big array, trying to avoid loops
 
@SteveRobbins lolz
 
An array without loops?
 
@SteveRobbins Errm... no. You literally cannot do that without looping. Not possible. array_map() and array_walk() are still loops, they're just C loops instead of PHP loops.
(and no, that doesn't necessarily make them faster/more efficient)
 
what dave said ^
 
@DaveRandom I understand that. I mean without php looping
 
10:19 PM
@SteveRobbins Why? Why so adamant against loops?
 
// Generating primes using en.wikipedia.org/wiki/Sieve_of_Eratosthenes
ini_set('memory_limit', '256M');

$limit = 2000000;
$list = range(3,$limit,2);
$primes = array(2);
$banned = array();
foreach($list as $n){
	if(!isset($banned[$n])){
		$primes[] = $n;
		if($n*2<$limit){
			$array = range($n*2,$limit+$n,$n);
			foreach($array as $arr){
				$banned[$arr] = 0;
			}
		}
	}
}

// $primes contain all the primes ....
@Farkie ^ primes
 
@cspray My question isn't why, it's how. If you can help me in this aspect, I would appreciate your input.
 
@SteveRobbins what's your expected output ?
 
@SteveRobbins The how question can only be reasonably be answered if we have all the info including the why
 
@SteveRobbins There's a pretty good chance that avoiding PHP loops will actually perform worse with such a simple operation on a large array due to the overhead of function calls. My money is on the simple $result = []; foreach ($arr as $el) $result[$el['value']] = $el['label']; being the best way to do this if you benchmark it.
 
10:22 PM
I would use goto
Just because it looks cool / retro
 
Why does goto even exist?
 
@SteveRobbins Also realistically a PHP loop is your only option, I now see having just written that ^^ because you need to use explicit keys and not just a simple push/modify
 
@DaveRandom I see. Thanks for this information. I appreciate the insight you're giving.
 
dunno why but i have a feeling a map or walk will perform better if crafted right
 
@AshwinMukhija There is only one person to blame
 
10:24 PM
who let the dogs out?
 
@kaᵠ You can't do $result[$el['value']] with map/walk though, that's the root of the problem with that
If you look at the sample output, the keys are based on values in the input
 
+call overhead
 
@JoeWatkins I imagine that blows any efficiency gain from the pure C loop pretty quickly, I'm trying to test it but I can't get a decent benchmark because my computer is... errr... busy.
(read: shit)
 
you will deffo be better to write the loop as php, it's not even worth benchmarking, it is common sense ... now if you were calling a builtin, maybe you'd have a chance of performing well with walk/map or the like, but calling a userland function a billion times is no competition ...
all the stack and unstack and unending zend_parse_parameters will absolutely, definitely kill it ...
 
10:29 PM
$array = array(array('value' => 1, 'label' => 'a'), array('value' => 2, 'label' => 'b'));
$new =  array();

array_map(function($v)use(&$new){
	$new[$v['value']] = $v['label'];
}, $array);

print_r($new);
Using array map lol :D
Probably much slower with & :p
 
why would it be slower with & ?
 
@JoeWatkins Reference ?
 
yes, but do you know what it actually does, and the difference between using it and not using it ??
 
@Gordon will be driving through your town today :)
 
@JoeWatkins I know how to use it for a certain result, but I don't know what's going on exactly internally ...
 
10:31 PM
how do you conclude that it would be slower ?
it should usually be quicker to pass references ...
 
@JoeWatkins Not sure when, but I think it was with a foreach loop, testing with and without &
 
@JoeWatkins I still don't get why using refs in foreach causes CoW. @NikiC has explained it in great detail a few times, I still just don't get why it needs to do it.
(tangentially related)
 
I dunno exactly how it is done for iteration, but usually foreach ($array as $key => $value) will result in $array[$key] being copied to $value for each iteration, foreach ($array as $key => &$value) will pass $array[$key] as $value directly ... shouldn't be slower ...
 
Cow ?
 
copy-on-write
 
10:34 PM
@JoeWatkins See that's what I think. But apparently foreach will do a full memcopy of the whole array if you use refs
 
@JoeWatkins I'm not sure on the subject, have read somewhere that it may be slower in some cases
 
jesus
 
then what the fuck is the point is supporting the reference operator if what you get is not a reference to the member of the array you are iterating over ...
 
@JoeWatkins If you haven't already seen it: stackoverflow.com/a/14854568/889949
 
10:36 PM
there is no good reason for that ... whether it can be explained or not doesn't make a bit of difference, it doesn't make good sense ...
 
@SteveRobbins did you see the code ?
 
@JoeWatkins It's to do with the array pointer more than the data I think. But (from what I understand) it still does a full copy of the array. NikiC can explain way better than I can, especially since what little I know on the subject is almost all learned directly from him.
 
I just don't get the way the collective thinks, I'm absolutely sure that none of us would implement it like that and be happy with it ... but because there's a million opinions, what becomes acceptable is absolutely mental ...
 
@HamZa Interesting approach. Thanks.
 
@SteveRobbins you're welcome ... You should maybe benchmark it with a normal foreach loop ...
 
10:42 PM
Who the fuck?
 
casperOne. It's always casperOne's fault.
 
Wait what?
 
5
Q: Why does PHP not save session variables for specific users with Internet Explorer?

Jan-HenkI have a problem with a website where PHP does not save session variables for specific users with Internet Explorer. But for some other users with Internet Explorer there is no problem at all, and users with other browsers also do not have any problems. I created the following three small scrip...

^ If anyone has an idea ...
 
const walking=true;
road: while (walking) goto road;
 
aaaaand NikiC is here
 
10:47 PM
@DaveRandom yeah, it seems the fastest way to foreach is without references ... pretty bizarre, even if there is an explanation, it is not expected ... codepad.viper-7.com/slcY9z
 
@JoeWatkins BAM told ya :p
 
@HamZaDzCyberDeV BAM indeed !!
 
In the real world it still isn't statistically significant because it's still only ~5ms difference for 100000 elements, but it's still counter intuitive
 
that why you don't use foreach
 
@kaᵠ do while loop ?
 
10:53 PM
while/for
 
@kaᵠ So you never need to iterate associative arrays then?
 
I wonder how would you iterate associative array with forloop, is that even possible (with a reliable way) ?
 
@HamZa I'm completely stumped on that one. I can only assume there is something we cannot see causing the problem, like (?) rewriting firing a hidden script or something
@HamZa It's possible, but it would be comically inefficient, the only way I can think of is $keys = array_keys($arr); for ($i = 0, $l = count($keys); $i < $l; $i++) { $el = $arr[$keys[$i]]; /* ... */ }
 
@DaveRandom exactly ...
 
^^ that basically iterates the array twice, once to extract the keys and then again to actually do something with it
 
10:59 PM
Yeah ...
but after thinking, foreach is a coded "feature" in C. So does C use a forloop o_o ?
 
@DaveRandom each()
?
what's wroing with that? ^
 
@HamZa It's not really relevant. Firstly it's C so it's compiled, and secondly the way PHP arrays work in C is so complex that the way the loops work doesn't matter. Associative arrays are (IIRC) implemented as a doubly-linked list so I imagine the links are just traversed
@kaᵠ I can't believe that's any more efficient than foreach and probably a lot less, also it's just generally horrible to work with :-P
 
hahhaha
 
prolly not, but it's a way
 
@HamZa evning
 
11:06 PM
@NikiC hello !
 
morning Niki
 
Later guys !
 
yo
@HamZa what's up
 
@Happyninja I'm going to sleep xD
 
@HamZa good night ;)
 
11:16 PM
@Happyninja thanks
 
hello, i'm trying to write a different greeting for different times of the day..
can anyone help me?
 
@ManolisC. date()
 
found lots of tutorials but can't find it out
 
11:25 PM
What have you tried? @ManolisC.
 
yes. @PeeHaa埽 i'm getting the date, but i'm stuck on the comparison
 
@ManolisC. We need to see code
 
And please isolate the problem code
 
11:27 PM
@ManolisC. how are you stuck? date("H") ...
 
well i'm using time()
 
so when it's 12.00 i want to write good morning.. when 21.00 good night for example
 
11:28 PM
@ManolisC. use date, time is something else
 
ok i'll try it now
 
is it possible to compare it like..
if (date("H") > 12) echo "good morning"; ?
 
@ManolisC. switch (date("H")) ?
@ManolisC. if (date("H") < 12) echo "good morning";
 
11:38 PM
> using Wordpress in all its glory
said no one ever
ow wait...
 
@kaᵠ i tried something similar.. let me show you
 
@ManolisC. See stackoverflow.com/a/14928837/1592648 it can be used to do the same thing, to print out whatever phrase you want depending on the time.
 
@crypticツ looks interesting! pretty confusing though :)
@kaᵠ
<?php
$time = date("H");
if ($time > 6 and $time <= 12) {
echo ("morning"); }
else if ($time > 12 and $time <= 18) {
echo ("afternoon");
}
else if ($time > 18 and $time <= 12) {
echo ("evening");
}
else if ($time >= 12 and $time <= 6) {
echo ("night");
}
?>
 
@ManolisC. the last block of code is the better approach
 
This is markdown ?
 
11:43 PM
@ManolisC. this will never work: else if ($time > 18 and $time <= 12) { > 18 is enough
@ManolisC. use codepad.viper-7.com
 
Anyone happen to know the complete list of functions that are not utf-8 safe in PHP? Is it just those that are extended in mb_string?
 
Wait, what is markdown?
 
@Danack I don't think so
 
11:48 PM
 
@PeeHaa埽 k - thanks anyway.
 
e.g. wordwrap
 
@kaᵠ it was because of the 24
@kaᵠ thank you!!
 
yw
 

« first day (956 days earlier)      last day (4008 days later) »