Skip to content

Commit 688c2ad

Browse files
committed
Update site
1 parent ade46f3 commit 688c2ad

File tree

73 files changed

+541
-228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+541
-228
lines changed

_octopress/source/_includes/custom/array.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!-- Generated by Rakefile:build -->
2+
- [array](/functions/array)
23
- [array_change_key_case](/functions/array_change_key_case)
34
- [array_chunk](/functions/array_chunk)
45
- [array_combine](/functions/array_combine)
@@ -55,7 +56,6 @@
5556
- [current](/functions/current)
5657
- [each](/functions/each)
5758
- [end](/functions/end)
58-
- [extract](/functions/extract)
5959
- [in_array](/functions/in_array)
6060
- [key](/functions/key)
6161
- [krsort](/functions/krsort)

_octopress/source/_includes/custom/asides/banners.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
<section>
2+
<h1>Build status</h1>
3+
4+
<p>
5+
<a href="https://travis-ci.org/kvz/phpjs"><img src="https://travis-ci.org/kvz/phpjs.png?branch=master" /></a>
6+
</p>
7+
28
<h1>Donate</h1>
39

410
<br />

_octopress/source/_includes/custom/asides/category_list.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ <h1>Categories</h1>
1616

1717
<li><a href="/categories/funchand">funchand</a></li>
1818

19+
<li><a href="/categories/i18n">i18n</a></li>
20+
1921
<li><a href="/categories/info">info</a></li>
2022

2123
<li><a href="/categories/json">json</a></li>

_octopress/source/_includes/custom/community.html

Lines changed: 22 additions & 20 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!-- Generated by Rakefile:build -->
22
- [basename](/functions/basename)
33
- [dirname](/functions/dirname)
4+
- [file_get_contents](/functions/file_get_contents)
45
- [pathinfo](/functions/pathinfo)
56
- [realpath](/functions/realpath)

_octopress/source/_includes/custom/funchand.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@
44
- [create_function](/functions/create_function)
55
- [function_exists](/functions/function_exists)
66
- [get_defined_functions](/functions/get_defined_functions)
7-
- [register_shutdown_function](/functions/register_shutdown_function)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<!-- Generated by Rakefile:build -->
2-
- [assert](/functions/assert)
32
- [assert_options](/functions/assert_options)
43
- [getenv](/functions/getenv)
54
- [getlastmod](/functions/getlastmod)
5+
- [ini_get](/functions/ini_get)
6+
- [ini_set](/functions/ini_set)
67
- [set_time_limit](/functions/set_time_limit)
78
- [version_compare](/functions/version_compare)

_octopress/source/_includes/custom/strings.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- [convert_uuencode](/functions/convert_uuencode)
1010
- [count_chars](/functions/count_chars)
1111
- [crc32](/functions/crc32)
12+
- [echo](/functions/echo)
1213
- [explode](/functions/explode)
1314
- [get_html_translation_table](/functions/get_html_translation_table)
1415
- [html_entity_decode](/functions/html_entity_decode)

_octopress/source/categories/array/index.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ footer: true
77
---
88
<!-- Generated by Rakefile:build -->
99

10+
- [array](/functions/array)
1011
- [array_change_key_case](/functions/array_change_key_case)
1112
- [array_chunk](/functions/array_chunk)
1213
- [array_combine](/functions/array_combine)
@@ -63,7 +64,6 @@ footer: true
6364
- [current](/functions/current)
6465
- [each](/functions/each)
6566
- [end](/functions/end)
66-
- [extract](/functions/extract)
6767
- [in_array](/functions/in_array)
6868
- [key](/functions/key)
6969
- [krsort](/functions/krsort)

_octopress/source/categories/filesystem/index.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ footer: true
99

1010
- [basename](/functions/basename)
1111
- [dirname](/functions/dirname)
12+
- [file_get_contents](/functions/file_get_contents)
1213
- [pathinfo](/functions/pathinfo)
1314
- [realpath](/functions/realpath)

_octopress/source/categories/funchand/index.markdown

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ footer: true
1212
- [create_function](/functions/create_function)
1313
- [function_exists](/functions/function_exists)
1414
- [get_defined_functions](/functions/get_defined_functions)
15-
- [register_shutdown_function](/functions/register_shutdown_function)

_octopress/source/categories/info/index.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ footer: true
77
---
88
<!-- Generated by Rakefile:build -->
99

10-
- [assert](/functions/assert)
1110
- [assert_options](/functions/assert_options)
1211
- [getenv](/functions/getenv)
1312
- [getlastmod](/functions/getlastmod)
13+
- [ini_get](/functions/ini_get)
14+
- [ini_set](/functions/ini_set)
1415
- [set_time_limit](/functions/set_time_limit)
1516
- [version_compare](/functions/version_compare)

_octopress/source/categories/strings/index.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ footer: true
1717
- [convert_uuencode](/functions/convert_uuencode)
1818
- [count_chars](/functions/count_chars)
1919
- [crc32](/functions/crc32)
20+
- [echo](/functions/echo)
2021
- [explode](/functions/explode)
2122
- [get_html_translation_table](/functions/get_html_translation_table)
2223
- [html_entity_decode](/functions/html_entity_decode)

_octopress/source/functions/addcslashes/index.markdown

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ function addcslashes (str, charlist) {
2424
// * returns 1: "\\f\\o\\o\\[ \\]"
2525
// * example 2: addcslashes("zoo['.']", 'z..A'); // Only escape z, period, and A here since not a lower-to-higher range
2626
// * returns 2: "\\zoo['\\.']"
27-
// * example 3: addcslashes("@a\u0000\u0010\u00A9", "\0..\37!@\177..\377") == '\\@a\\000\\020\\302\\251'); // Escape as octals those specified and less than 32 (0x20) or greater than 126 (0x7E), but not otherwise
28-
// * returns 3: true
29-
// * example 4: addcslashes("\u0020\u007E", "\40..\175") == '\\ ~'); // Those between 32 (0x20 or 040) and 126 (0x7E or 0176) decimal value will be backslashed if specified (not octalized)
30-
// * returns 4: true
27+
// * example 3: addcslashes("@a\u0000\u0010\u00A9", "\0..\37!@\177..\377"); // Escape as octals those specified and less than 32 (0x20) or greater than 126 (0x7E), but not otherwise
28+
// * returns 3: '\\@a\\000\\020\\302\\251'
29+
// * example 4: addcslashes("\u0020\u007E", "\40..\175"); // Those between 32 (0x20 or 040) and 126 (0x7E or 0176) decimal value will be backslashed if specified (not octalized)
30+
// * returns 4: '\\ ~'
3131
// * example 5: addcslashes("\r\u0007\n", '\0..\37'); // Recognize C escape sequences if specified
3232
// * returns 5: "\\r\\a\\n"
3333
// * example 6: addcslashes("\r\u0007\n", '\0'); // Do not recognize C escape sequences if not specified
34-
// * returns 7: "\r\u0007\n"
34+
// * returns 6: "\r\u0007\n"
3535
var target = '',
3636
chrs = [],
3737
i = 0,
@@ -201,12 +201,12 @@ Should return
201201
### Example 3
202202
This code
203203
{% codeblock lang:js example %}
204-
addcslashes("@a\u0000\u0010\u00A9", "\0..\37!@\177..\377") == '\\@a\\000\\020\\302\\251'); // Escape as octals those specified and less than 32 (0x20) or greater than 126 (0x7E), but not otherwise
204+
addcslashes("@a\u0000\u0010\u00A9", "\0..\37!@\177..\377"); // Escape as octals those specified and less than 32 (0x20) or greater than 126 (0x7E), but not otherwise
205205
{% endcodeblock %}
206206

207207
Should return
208208
{% codeblock lang:js returns %}
209-
true
209+
'\\@a\\000\\020\\302\\251'
210210
{% endcodeblock %}
211211

212212

_octopress/source/functions/array/index.markdown

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,24 @@ A JavaScript equivalent of PHP's array
1616

1717
{% codeblock array/array.js lang:js https://raw.github.com/kvz/phpjs/master/functions/array/array.js raw on github %}
1818
function array () {
19-
// http://kevin.vanzonneveld.net
19+
// From: http://phpjs.org/functions
2020
// + original by: d3x
2121
// + improved by: Brett Zamir (http://brett-zamir.me)
22+
// * test: skip
2223
// * example 1: array('Kevin', 'van', 'Zonneveld');
2324
// * returns 1: ['Kevin', 'van', 'Zonneveld']
2425
// * example 2: ini_set('phpjs.return_phpjs_arrays', 'on');
25-
// * example 2: var arr = array({0:2}, {a:41}, {2:3}).change_key_case('CASE_UPPER').keys();
26+
// * example 2: array({0:2}, {a:41}, {2:3}).change_key_case('CASE_UPPER').keys();
2627
// * returns 2: [0,'A',2]
2728

29+
try {
30+
this.php_js = this.php_js || {};
31+
} catch (e) {
32+
this.php_js = {};
33+
}
34+
2835
var arrInst, e, __, that = this, PHPJS_Array = function PHPJS_Array() {},
29-
mainArgs = arguments, p = this.php_js = this.php_js || {},
36+
mainArgs = arguments, p = this.php_js,
3037
_indexOf = function (value, from, strict) {
3138
var i = from || 0, nonstrict = !strict, length = this.length;
3239
while (i < length) {
@@ -320,8 +327,17 @@ function array () {
320327
}
321328
{% endcodeblock %}
322329

323-
- [view on github](https://github.com/kvz/phpjs/blob/master/functions/array/array.js)
324-
- [edit on github](https://github.com/kvz/phpjs/edit/master/functions/array/array.js)
330+
- [Raw function on GitHub](https://github.com/kvz/phpjs/blob/master/functions/array/array.js)
331+
332+
Please note that php.js uses JavaScript objects as substitutes for PHP arrays, they are
333+
the closest match to this hashtable-like data structure.
334+
335+
Please also note that php.js offers community built functions and goes by the
336+
[McDonald's Theory](https://medium.com/what-i-learned-building/9216e1c9da7d). We'll put online
337+
functions that are far from perfect, in the hopes to spark better contributions.
338+
Do you have one? Then please just:
339+
340+
- [Edit on GitHub](https://github.com/kvz/phpjs/edit/master/functions/array/array.js)
325341

326342
### Example 1
327343
This code
@@ -338,7 +354,7 @@ Should return
338354
This code
339355
{% codeblock lang:js example %}
340356
ini_set('phpjs.return_phpjs_arrays', 'on');
341-
var arr = array({0:2}, {a:41}, {2:3}).change_key_case('CASE_UPPER').keys();
357+
array({0:2}, {a:41}, {2:3}).change_key_case('CASE_UPPER').keys();
342358
{% endcodeblock %}
343359

344360
Should return

_octopress/source/functions/array_change_key_case/index.markdown

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ function array_change_key_case (array, cs) {
1919
// From: http://phpjs.org/functions
2020
// + original by: Ates Goral (http://magnetiq.com)
2121
// + improved by: marrtins
22-
// + improved by: Brett Zamir (http://brett-zamir.me)
22+
// + improved by: Brett Zamir (http://brett-zamir.me)
2323
// * example 1: array_change_key_case(42);
2424
// * returns 1: false
2525
// * example 2: array_change_key_case([ 3, 5 ]);
26-
// * returns 2: {0: 3, 1: 5}
26+
// * returns 2: [3, 5]
2727
// * example 3: array_change_key_case({ FuBaR: 42 });
2828
// * returns 3: {"fubar": 42}
2929
// * example 4: array_change_key_case({ FuBaR: 42 }, 'CASE_LOWER');
@@ -33,10 +33,10 @@ function array_change_key_case (array, cs) {
3333
// * example 6: array_change_key_case({ FuBaR: 42 }, 2);
3434
// * returns 6: {"FUBAR": 42}
3535
// * example 7: ini_set('phpjs.return_phpjs_arrays', 'on');
36-
// * example 7: var arr = array({a: 0}, {B: 1}, {c: 2});
36+
// * example 7: var arr = [{a: 0}, {B: 1}, {c: 2}];
3737
// * example 7: var newArr = array_change_key_case(arr);
38-
// * example 7: newArr.b
39-
// * example 7: 1
38+
// * example 7: newArr.splice(1, 1);
39+
// * returns 7: {b: 1}
4040

4141
var case_fn, key, tmp_ar = {};
4242

@@ -53,6 +53,7 @@ function array_change_key_case (array, cs) {
5353
}
5454
return tmp_ar;
5555
}
56+
5657
return false;
5758
}
5859
{% endcodeblock %}
@@ -88,7 +89,7 @@ array_change_key_case([ 3, 5 ]);
8889

8990
Should return
9091
{% codeblock lang:js returns %}
91-
{0: 3, 1: 5}
92+
[3, 5]
9293
{% endcodeblock %}
9394

9495
### Example 3

_octopress/source/functions/array_count_values/index.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function array_count_values (array) {
2929
// * returns 2: {3:2, 5:1, "foo":2, "bar":1}
3030
// * example 3: array_count_values([ true, 4.2, 42, "fubar" ]);
3131
// * returns 3: {42:1, "fubar":1}
32+
3233
var tmp_arr = {},
3334
key = '',
3435
t = '';
@@ -67,6 +68,7 @@ function array_count_values (array) {
6768
}
6869
}
6970
}
71+
7072
return tmp_arr;
7173
}
7274
{% endcodeblock %}

_octopress/source/functions/array_fill_keys/index.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function array_fill_keys (keys, value) {
2222
// * example 1: keys = {'a': 'foo', 2: 5, 3: 10, 4: 'bar'}
2323
// * example 1: array_fill_keys(keys, 'banana')
2424
// * returns 1: {"foo": "banana", 5: "banana", 10: "banana", "bar": "banana"}
25+
2526
var retObj = {},
2627
key = '';
2728

_octopress/source/functions/array_filter/index.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function array_filter (arr, func) {
2727
// * example 2: var even = function (num) {return (!(num & 1));}
2828
// * example 2: array_filter([6, 7, 8, 9, 10, 11, 12], even);
2929
// * returns 2: {0: 6, 2: 8, 4: 10, 6: 12}
30-
// * example 3: var arr = array_filter({"a": 1, "b": false, "c": -1, "d": 0, "e": null, "f":'', "g":undefined});
30+
// * example 3: array_filter({"a": 1, "b": false, "c": -1, "d": 0, "e": null, "f":'', "g":undefined});
3131
// * returns 3: {"a":1, "c":-1};
3232

3333
var retObj = {},
@@ -89,7 +89,7 @@ Should return
8989
### Example 3
9090
This code
9191
{% codeblock lang:js example %}
92-
var arr = array_filter({"a": 1, "b": false, "c": -1, "d": 0, "e": null, "f":'', "g":undefined});
92+
array_filter({"a": 1, "b": false, "c": -1, "d": 0, "e": null, "f":'', "g":undefined});
9393
{% endcodeblock %}
9494

9595
Should return

_octopress/source/functions/array_flip/index.markdown

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ A JavaScript equivalent of PHP's array_flip
1818
function array_flip (trans) {
1919
// From: http://phpjs.org/functions
2020
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
21-
// + improved by: Pier Paolo Ramon (http://www.mastersoup.com/)
22-
// + improved by: Brett Zamir (http://brett-zamir.me)
21+
// + improved by: Pier Paolo Ramon (http://www.mastersoup.com/)
22+
// + improved by: Brett Zamir (http://brett-zamir.me)
23+
// - depends on: array
24+
// * test: skip
2325
// * example 1: array_flip( {a: 1, b: 1, c: 2} );
2426
// * returns 1: {1: 'b', 2: 'c'}
2527
// * example 2: ini_set('phpjs.return_phpjs_arrays', 'on');
@@ -28,12 +30,15 @@ function array_flip (trans) {
2830

2931
var key, tmp_ar = {};
3032

31-
if (trans && typeof trans=== 'object' && trans.change_key_case) { // Duck-type check for our own array()-created PHPJS_Array
33+
// Duck-type check for our own array()-created PHPJS_Array
34+
if (trans && typeof trans === 'object' && trans.change_key_case) {
3235
return trans.flip();
3336
}
3437

3538
for (key in trans) {
36-
if (!trans.hasOwnProperty(key)) {continue;}
39+
if (!trans.hasOwnProperty(key)) {
40+
continue;
41+
}
3742
tmp_ar[trans[key]] = key;
3843
}
3944

_octopress/source/functions/array_search/index.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ function array_search (needle, haystack, argStrict) {
2020
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
2121
// + input by: Brett Zamir (http://brett-zamir.me)
2222
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
23+
// - depends on: array
24+
// * test: skip
2325
// * example 1: array_search('zonneveld', {firstname: 'kevin', middle: 'van', surname: 'zonneveld'});
2426
// * returns 1: 'surname'
2527
// * example 2: ini_set('phpjs.return_phpjs_arrays', 'on');

_octopress/source/functions/array_walk/index.markdown

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ function array_walk (array, funcname, userdata) {
2020
// + original by: Johnny Mast (http://www.phpvrouwen.nl)
2121
// + bugfixed by: David
2222
// + improved by: Brett Zamir (http://brett-zamir.me)
23-
// % note 1: Using ini_set('phpjs.no-eval', true) will only work with
24-
// % note 1: user-defined string functions, not built-in functions like void()
23+
// - depends on: array
24+
// % note 1: Using ini_set('phpjs.no-eval', true) will only work with
25+
// % note 1: user-defined string functions, not built-in functions like void()
26+
// * test: skip
2527
// * example 1: array_walk ({'a':'b'}, 'void', 'userdata');
2628
// * returns 1: true
2729
// * example 2: array_walk ('a', 'void', 'userdata');
@@ -33,7 +35,7 @@ function array_walk (array, funcname, userdata) {
3335
// * example 5: ini_set('phpjs.return_phpjs_arrays', 'on');
3436
// * example 5: var arr = array({40: 'My age'}, {50: 'My IQ'});
3537
// * example 5: array_walk(arr, [window, 'prompt']);
36-
// * returns 5: [object Object]
38+
// * returns 5: '[object Object]'
3739
var key, value, ini;
3840

3941
if (!array || typeof array !== 'object') {

_octopress/source/functions/convert_uuencode/index.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function convert_uuencode (str) {
2323
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
2424
// - depends on: is_scalar
2525
// * example 1: convert_uuencode("test\ntext text\r\n");
26-
// * returns 1: '0=&5S=`IT97AT('1E>'0-"@``'
26+
// * returns 1: "0=&5S=`IT97AT('1E>'0-\"@``"
2727
// shortcut
2828
var chr = function (c) {
2929
return String.fromCharCode(c);
@@ -118,7 +118,7 @@ convert_uuencode("test\ntext text\r\n");
118118

119119
Should return
120120
{% codeblock lang:js returns %}
121-
'0=&5S=`IT97AT('1E>'0-"@``'
121+
"0=&5S=`IT97AT('1E>'0-\"@``"
122122
{% endcodeblock %}
123123

124124

_octopress/source/functions/dirname/index.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ A JavaScript equivalent of PHP's dirname
1616

1717
{% codeblock filesystem/dirname.js lang:js https://raw.github.com/kvz/phpjs/master/functions/filesystem/dirname.js raw on github %}
1818
function dirname (path) {
19-
// From: http://phpjs.org/functions
19+
// http://kevin.vanzonneveld.net
2020
// + original by: Ozh
2121
// + improved by: XoraX (http://www.xorax.info)
2222
// * example 1: dirname('/etc/passwd');
@@ -25,6 +25,7 @@ function dirname (path) {
2525
// * returns 2: 'c:/Temp'
2626
// * example 3: dirname('/dir/test/');
2727
// * returns 3: '/dir'
28+
2829
return path.replace(/\\/g, '/').replace(/\/[^\/]*\/?$/, '');
2930
}
3031
{% endcodeblock %}

0 commit comments

Comments
 (0)