Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.php Subject: Re: solved Date: Wed, 20 Nov 2013 16:02:49 +0100 Lines: 89 Message-ID: <528CCF19.6000204@arnowelzel.de> References: <93xuovoqvo59.1wcgm8i5gn2hb$.dlg@40tude.net> <1939vbqgxpb1.1ed40enyqnzu1$.dlg@40tude.net> <528B952D.9090500@arnowelzel.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: individual.net YdE+EcpTNmUukDNUCa5sBQrDnAyCrTRmYC0NJTswdgBiR0qo26 Cancel-Lock: sha1:8kfO0m/chpDn5iwwn+NpegsTTYc= User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 In-Reply-To: Xref: csiph.com comp.lang.php:11879 Am 19.11.2013 20:41, schrieb richard: > On Tue, 19 Nov 2013 17:43:25 +0100, Arno Welzel wrote: > >> Am 19.11.2013 03:45, schrieb richard: >>> >> >>> $track=$_GET['item']; >>> >>> >>> $asong=$six0[$track][0]; >>> $flip=$six0[$track][1]; >>> >>> $max=count($six0); >>> >>> $match=0; >>> >>> for ($item=0;$item<=$max;$item++){ >>> if ($flip==$six0[$item]['0']) >>> {if ($six0[$item][2]=$six0[$track][2]) >>> {$match=$item;}} >>> } >> >> PLEASE format your code properly! >> >> for($item=0; $item <= $max; $item++) >> { >> if($flip == $six0[$item]['0']) >> { >> if($six0[$item][2] = $six0[$track][2]) >> { >> $match = $item; >> } >> } >> } >> >> And why this? >> >> if($six0[$item][2] = $six0[$track][2]) >> >> Please note: "=" is NOT the same as "=="! >> >> If you want to COMPARE $six0[$item][2] and $six0[$track][2] you MUST write: >> >> if($six0[$item][2] == $six0[$track][2]) > > The script works if it were on one line or 100 lines. READ what I wrote. I said nothing about the question, if your code works or not - but I doubt, that you really *know* what the difference is between: if($six0[$item][2] = $six0[$track][2]) and if($six0[$item][2] == $six0[$track][2]) Do you? Can you explain, why your code uses the assignement and not the comparison? Some how it feels if I already explained this a dozen times and I just forgot that... > You've never seen a page where the source code was 10,000 characters long > all on one single line? I did. And you don't see any difference in readability above in your version and my formatted version? Also see here: But this does not mean, that such code is *readable* nor that I recommend to write code this way. In this special case () it is a "compressed" JavaScript to save bandwidth and lower the number of HTTP requests needed. But this is constructed dynamically by js.php which takes the local JavaScript files and creates a big "compressed" version of them in one single block. But for scripts which remains on the server and will never be transmitted to the client it should be *readable* for *humans*. -- Arno Welzel http://arnowelzel.de http://de-rec-fahrrad.de