phpjs
Version:
118 lines (93 loc) • 3.25 kB
HTML
<!-- Generated by Rakefile:build -->
<strong>
<a href="http://brett-zamir.me" rel="nofollow">Brett Zamir</a>
</strong>
on 2012-09-18 17:29:30 <br />
@Marek Spak: That's basically what we're doing, with a little extra to cover the PHP API more exactly. See the Wiki/FAQ for project goals.
<hr />
<strong>
<a href="http://www.sanderundspak.de" rel="nofollow">Marek Spak</a>
</strong>
on 2012-08-01 11:35:06 <br />
or you could just use join on the array. like this
<pre><code>
['hello','world','!!!'].join(' ') //return "hello world !!!"
</code></pre>
or am i missing something?
<hr />
<strong>
<a href="http://brett-zamir.me" rel="nofollow">Brett Zamir</a>
</strong>
on 2011-09-19 20:42:23 <br />
@ionut: It ensures that the first time in the loop it will use an empty string, but use the glue for subsequent loops.
<hr />
<strong>
<a href="http://ionutpopa.tumblr.com" rel="nofollow">ionut</a>
</strong>
on 2011-09-19 11:12:14 <br />
Hi,
Why do you declare <pre><code>tGlue = glue;</code></pre> in the loop each time?
<hr />
<strong>
<a href="http://brett-zamir.me" rel="nofollow">Brett Zamir</a>
</strong>
on 2011-09-14 10:56:36 <br />
Glad you find the site helpful, Krrish. I recommend reading JavaScript: The Definitive Guide and JavaScript: The Good Parts.
<hr />
<strong>
<a href="http://itech.hubpages.com" rel="nofollow">Krrish</a>
</strong>
on 2011-09-13 12:21:15 <br />
Excellent Work...
Well, I already developed one web 2.0 application (For Personal Use)... But Still having problems in mastering JavaScript (Especially JavaScript arrays)...
Bookmarked it for future reference.
Thanks
<hr />
<strong>
<a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a>
</strong>
on 2009-10-25 13:29:50 <br />
@ Itsacon: Excellent!
<hr />
<strong>
<a href="http://brett-zamir.me" rel="nofollow">Brett Zamir</a>
</strong>
on 2009-10-12 22:43:58 <br />
@Itsacon: Thanks very much! There may be a few other functions out there like that that only work with true arrays, so it is very good to have your fix. FYI, I declared retVal, tGlue, and i with 'var' so they would not be globals. It is now fixed in git: http://github.com/kvz/phpjs/commit/e00889a7914df1e91640b7222d56eee30c20ec97
<hr />
<strong>
<a href="http://www.itsacon.net/" rel="nofollow">Itsacon</a>
</strong>
on 2009-10-09 13:32:59 <br />
This is a follow-up on the discussion at the array_diff() function.
The implode function is currently incompatible with most of the array_xxx() functions. Those functions often return objects instead of Arrays, but the implode() function actively checks for Arrays, and returns objects un-imploded.
I made a slight alteration, parsing all object properties as well.
<pre><code>function implode(glue,pieces)
{
if(arguments.length == 1)
{
pieces = glue;
glue = '';
}
if(typeof(pieces)=='object')
{
if(pieces instanceof Array)
return pieces.join(glue);
else
{
retVal='', tGlue='';
for(i in pieces)
{
retVal += tGlue + pieces[i];
tGlue = glue;
}
return retVal;
}
}
else
{
return pieces;
}
}</code></pre>
I also made the function compatible with the PHP 4.3.0 alteration that made the glue parameter optional.
<hr />