Welcome To Snipplr


Everyone's Recent Snippets Tagged array



1 ... 5 6 7 8 9 ... 13
0 1195 posted 13 years ago by metoikos
I frequently pass an array of elements from an HTML form to PHP, normally a list of checkboxes for removing database records. This will loop through an array of checkbox's with the same name & build a delimited string from the checked values. Afte...
0 562 posted 13 years ago by verostudios
1 664 posted 13 years ago by iloveitaly
After i saw this snippet http://snipplr.com/view/33790/form-country-code-select-with-if-selected-test/ i wanted to make the code better :D To make it easier to maintain
0 780 posted 14 years ago by cigraphics
I found this awesome function that allows you to easily remove duplicate values.
4 1451 posted 14 years ago by chrisaiv
The first argument is a variable name which value should be extracted from $array (second argument), or array of keys (multidim array is also supported). The third argument is a default value which will be return on fail (false by default). Usage...
0 740 posted 14 years ago by and
split_to_chunks splits the string up into an array with elements containing 140 characters <b>or less</b>. This enables you to keep words intact when sending automated twitter messages. $to is needed in order to subtract from 140 the amount of cha...
0 868 posted 14 years ago by s0l1dsnak3123
0 564 posted 14 years ago by alejandrosuch
This function takes an array and a key that is unwanted. It will recurse through and unset the key in the argument array and all its sub-arrays.
0 621 posted 14 years ago by thesmart
I needed to break down a long string today and insert line breaks so I wrote this little function. You can use it to split a long string into chunks of a defined length and get them as an array or join them by a defined character (e.g. &lt;br /&gt;)....
0 779 posted 14 years ago by chlab
0 526 posted 14 years ago by paramah
2 729 posted 14 years ago by frankyfish
I always forget which method does what. This is just as a quick reminder.
4 2643 posted 14 years ago by adrianparr
If the item cannot be found then the return value is NaN. This function only returns the index of the first occurence found, so it's not very good if you have multiple occurrences of the same value in the array.
0 2198 posted 14 years ago by adrianparr
0 899 posted 14 years ago by inkdeep
0 654 posted 14 years ago by inkdeep
I'm not sure whether I should be using == (Equality) or === (Strict equality) here. I haven't been able to create a situation where it makes much difference. If you know better, feel free to leave me a comment.
0 985 posted 14 years ago by adrianparr
i could put a demo of this in action if you want
0 818 posted 14 years ago by abbey
Notes to self: re-use this for other projects
0 1163 posted 14 years ago by abbey
I include this in anything I'm developing, so I can easily inspect the contents of arrays and objects.
0 663 posted 14 years ago by joshuamilford
listsEqual(["1","2"], ["1","2"]) is true;
0 604 posted 14 years ago by prudnikov
This SearchArray class was written by Flanture. I claim no credit for this. The class can be downloaded from here ... http://www.box.net/shared/7fj14higai
2 635 posted 14 years ago by adrianparr
Orders a multi-dimensional array by one of it's fields. There is also the option to treat this like an SQL-style 'order by' query with the $field value passed in (ie. 'user_id desc') to do reverse ordering.
0 476 posted 14 years ago by browncardigan
1 503 posted 14 years ago by rccc
Array associativa de estados brasileiros com sigla pra chave e nome para valor.
0 801 posted 14 years ago by rudwolf
1 ... 5 6 7 8 9 ... 13