phpjs
Version:
223 lines (175 loc) • 6.71 kB
HTML
<!-- Generated by Rakefile:build -->
<strong>
<a href="http://an3m1.com/" rel="nofollow">????? ????</a>
</strong>
on 2012-04-17 15:33:14 <br />
If I might —perhaps you should consider adding a few images. I don’t mean to disrespect what you’ve said ; its very enlightening, indeed. However, I think would respond to it more positively if they could be something tangible to your ideas
<hr />
<strong>
aaa
</strong>
on 2011-08-27 21:18:20 <br />
ewewe
<hr />
<strong>
<a href="http://www.actionenergy.pl" rel="nofollow">baterie s?oneczne</a>
</strong>
on 2010-09-05 16:56:38 <br />
Wow! it seems that someone did really great stuff here! Lovely!
<hr />
<strong>
<a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a>
</strong>
on 2008-12-10 17:22:44 <br />
@ Ates Goral: Wow thanks a lot Ates! We'll leave it open for improvement then! Though I don't really like the idea of global variables, I believe the include_once functions also already work like that so we may be able to do that here as well. What do you think?
<hr />
<strong>
<a href="http://magnetiq.com" rel="nofollow">Ates Goral</a>
</strong>
on 2008-12-05 06:27:32 <br />
Perhaps the each() implementation I have below is a hasty one. It won't play nice with reset(), next() and previous(). It can be improved by actually storing the cursor position instead of consuming the key array with the shift(). I'll try to improve it and provide reset/next/prev if I find the time.
<hr />
<strong>
<a href="http://magnetiq.com" rel="nofollow">Ates Goral</a>
</strong>
on 2008-12-05 06:22:48 <br />
I apologize for the earlier, unformatted post :)
<pre><code>
function each(arr) {
// Return the current key and value pair from an array and advance the array cursor
// + original by: Ates Goral (http://magnetiq.com)
// * example 1: each([42,43]);
// * returns 1: {0: 0, 1: 42, key: 0, value: 42}
// * example 2: each({a:&quot;apple&quot;,b:&quot;balloon&quot;});
// * returns 2: {0:&quot;a&quot;,1:&quot;apple&quot;,key:&quot;a&quot;,value:&quot;apple&quot;}
if (!(arr instanceof Object) || (arr._keys &amp;&amp; !arr._keys.length)) {
return false;
}
if (!arr._keys) {
arr._keys = [];
for (var k in arr) {
if (k != &quot;_keys&quot;) {
arr._keys.push(k);
}
}
}
var k = arr._keys.shift();
var v = arr[k];
return {
0: k,
1: v,
key: k,
value: v
};
}
</code></pre>
<hr />
<strong>
<a href="http://magnetiq.com" rel="nofollow">Ates Goral</a>
</strong>
on 2008-12-05 06:19:53 <br />
function each(arr) {
// Return the current key and value pair from an array and advance the array cursor
// + original by: Ates Goral (http://magnetiq.com)
// * example 1: each([42,43]);
// * returns 1: {0: 0, 1: 42, key: 0, value: 42}
// * example 2: each({a:&quot;apple&quot;,b:&quot;balloon&quot;});
// * returns 2: {0:&quot;a&quot;,1:&quot;apple&quot;,key:&quot;a&quot;,value:&quot;apple&quot;}
if (!(arr instanceof Object) || (arr._keys &amp;&amp; !arr._keys.length)) {
return false;
}
if (!arr._keys) {
arr._keys = [];
for (var k in arr) {
if (k != &quot;_keys&quot;) {
arr._keys.push(k);
}
}
}
var k = arr._keys.shift();
var v = arr[k];
return {
0: k,
1: v,
key: k,
value: v
};
}
<hr />
<strong>
<a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a>
</strong>
on 2008-12-01 09:31:43 <br />
@ Sean &amp; Onno Marsman: I totally agree with Onno. If we can't get it right, and people have to learn a different notation anyway, let's just stick with JavaScript.
<hr />
<strong>
Onno Marsman
</strong>
on 2008-11-30 08:53:16 <br />
@Sean: We already can create associative arrays with JS:
<pre><code>
{
'first': 'kevin',
'last': 'Zonnevelt' //I don't know why this is with a T ;)
}
</code></pre>
Technically this is not an array but an object, but your proposal wouldn't return anything different. So we already have a syntax that is &quot;not quite the same as php&quot; and it does exactly the same.
Also think of using variables:
<pre><code>
{ a: b, c: d}
</code></pre>
Your alternative would result in something like this, because proper escaping is needed:
<pre><code>
array(&quot; '&quot;+addslashes(a)+&quot;' =&gt; '&quot;+addslashes(b)+&quot;' &quot;, &quot; '&quot;+addslashes(c)+&quot;' =&gt; '&quot;+addslashes(d)+&quot;' &quot; );
</code></pre>
I hope I didn't make any typo's, but I think my point is clear.
<hr />
<strong>
Sean
</strong>
on 2008-11-29 20:59:46 <br />
@Kevin: Could you not do:
<pre><code>
array(&quot; 'first' =&gt; 'kevin' &quot;, &quot; 'last' =&gt; 'Zonnevelt' &quot; );
</code></pre>
It's not quite the same as php, but at least this way you could create hash arrays
<hr />
<strong>
<a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a>
</strong>
on 2008-10-06 12:09:36 <br />
@ thinsoldier: Yes that would be very nice, but I don't see how we could implement that unfortunately :( Here we run against the hard wall of language differences.
<hr />
<strong>
thinsoldier
</strong>
on 2008-10-05 10:08:55 <br />
what about
array('first'=&gt;'Kevin', 'last'=&gt;'Zonnevelt')
<hr />
<strong>
<a href="http://www.cornicescentre.co.uk" rel="nofollow">covings</a>
</strong>
on 2008-09-09 18:15:57 <br />
VERY INTERESTING AND REALLY USEFUL INFORMATIONS! THX SO MUTCH
<hr />
<strong>
<a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a>
</strong>
on 2008-06-19 18:29:16 <br />
@ thinsoldier: What about them? Judging by your comment I would think you mean that our asort doesn't support them.. But it appears we don't have an asort yet ;)
JavaScript does support them in general. But they're called objects to be strict.
But I guess I don't fully understand your question.
<hr />
<strong>
thinsoldier
</strong>
on 2008-06-19 17:13:13 <br />
what about associative arrays?
var Divs = array(); // array of divs that I want to sort
Divs['amelie'] = divHtmlElement3;
Divs['randolph'] = divHtmlElement1;
Divs['judy'] = divHtmlElement9;
asort(Divs);
showDivArray(Divs);
<hr />