Welcome To Snipplr
Everyone's Recent Snippets Tagged array
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
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
707
posted 14 years ago by verostudios
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
938
posted 14 years ago by cigraphics
I found this awesome function that allows you to easily remove duplicate values.
4
1674
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
908
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
1047
posted 14 years ago by s0l1dsnak3123
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
759
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. <br />)....
0
974
posted 14 years ago by chlab
I always forget which method does what. This is just as a quick reminder.
4
2879
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
2522
posted 14 years ago by adrianparr
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
1159
posted 14 years ago by adrianparr
I include this in anything I'm developing, so I can easily inspect the contents of arrays and objects.
0
823
posted 14 years ago by joshuamilford
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
799
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
623
posted 14 years ago by browncardigan
Array associativa de estados brasileiros com sigla pra chave e nome para valor.
0
951
posted 14 years ago by rudwolf