Welcome To Snipplr


Everyone's Recent Snippets Tagged array



1 ... 5 6 7 8 9 ... 13
0 1712 posted 15 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 1131 posted 15 years ago by verostudios
1 1258 posted 15 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 1394 posted 15 years ago by cigraphics
I found this awesome function that allows you to easily remove duplicate values.
4 2373 posted 15 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 1352 posted 15 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 1590 posted 15 years ago by s0l1dsnak3123
0 1054 posted 15 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 1067 posted 15 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 1452 posted 15 years ago by chlab
0 1015 posted 15 years ago by paramah
2 1515 posted 15 years ago by frankyfish
I always forget which method does what. This is just as a quick reminder.
4 3666 posted 15 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 3159 posted 15 years ago by adrianparr
0 1522 posted 15 years ago by inkdeep
0 1233 posted 15 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 1668 posted 15 years ago by adrianparr
i could put a demo of this in action if you want
0 1511 posted 15 years ago by abbey
Notes to self: re-use this for other projects
0 1945 posted 15 years ago by abbey
I include this in anything I'm developing, so I can easily inspect the contents of arrays and objects.
0 1308 posted 15 years ago by joshuamilford
listsEqual(["1","2"], ["1","2"]) is true;
0 1132 posted 15 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 1158 posted 15 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 947 posted 15 years ago by browncardigan
1 936 posted 15 years ago by rccc
Array associativa de estados brasileiros com sigla pra chave e nome para valor.
0 1316 posted 15 years ago by rudwolf
1 ... 5 6 7 8 9 ... 13