Hi all,
In a case where you would like to reset an array of boolean values what is faster, rediming the array or enumerating and resetting the values?
I have run some tests and they seem to suggest that a redim is a lot faster but I am not convinced that it isnt a result of how I’m running the tests.
My tests seem to suggest that re...
I have a two-dimensional array:
function getMatrix(size) {
var matrix = [];
for (var i = 0; i < size; i++) {
matrix[i] = new Array(size);
}
return matrix;
};
It is filled with numeric values, so every existing matrix[i][j] is a Number. What is the best way to get a sequence of i and j pairs that will correspon...
I want to get all ids from a collection of items, how can I make this one short line:
var ids = [];
$(".post").each(function(index, element) {
ids.push($(element).attr("id"));
});
Something like:
var ids = $(".post").map("id");
Thanks.
...
hi,
i have an array that can contain the same value more than once. What I'm trying to find is a way to compare the values inside that array and output every value only once.
$_just_a_tier = array();
foreach ($_associatedProducts as $_item){
// count all products
$_tierprice = $this->getTierPrices($_item);
foreach ($_tierpri...
Hi,
I have a hashmap that I have created to control the events for buttons. It is defined as so:
var Signage_Manager = {
init: function() {
Signage_Manager.buttonActions.set_events();
},
buttonActions: {
buttons: {
'#add_product': {action: 'navigate', href: '/manager/add_product'},
'.back_to_dashboard': {act...
Hi,
I have a string, which is comes from js using encodeURICompoent(). Now i would like to convert this string into array. I tried my level best to solve this. But i couldn't find any solution to do this. Any help greatly appreciated.
array string = 'array(0=>array("packid"=>22,"pverid"=>18,"yaml"=>"- url: /static
static_dir: static
...
Hi everybody,
I am sure that this is super easy and built-in function in PHP, but I have yet not seen it.
Here's what I am doing for the moment:
forEach($array as $key => $value) {
echo $key; // Would output "subkey" in the example array
print_r($value);
}
Could I do something like the following instead and thereby save myse...
I've created a very simple asp.net web page for generating some HTML. The idea is that each time the user clicks the button previous inputs gets stored into an array and is then listed together with the most recent input. The problem is that the array resets for each clicks, the same goes for the counter I've made (using "i" as integer a...
I have an array and I am making a hash instance from it.
For instance, if array is:
@folders=(temp,usr,bin);
then i want to fill in hash:
$the_path{$folders[0]}{$folders[1]}{$folders[2]}="somevalue";
But if the array is only:
@folders=(bin);
then i want the path to be:
$the_path{$folders[0]}="somevalue";
The problem is I don...
Hay guys, i have an array contain this data
Array
(
[id] => Array
(
[0] => 1
[1] => 10
[2] => 4
)
[age] => Array
(
[0] => 1
[1] => 1
[2] => 2
)
)
Now i want to remove duplicates from the ['age'] and leave the first one ...
Here's where I am:
I started with an array...cleaned it up using 'regex'.
Now I have this...each item has three values
mystring = 4|black|cat, 7|red|dog, 12|blue|fish
Here's where I want to be:
I want to end up with three arrays.
array1=("4","7","12")
array2=("black","red","blue")
array3=("cat","dog","fish")
I also want to do thi...
I have an array that I wish to sort, it contains images with file extensions, the filename is numeric and the file extension is obviously a string.
$files = array();
$files[] = '4.jpg';
$files[] = '14.jpg';
$files[] = '1.jpg';
$files[] = '44.jpg';
If i use sort() then I end up with the following:
sort($files);
print_r($files);
Array...
I have two arrays (dividend, divisor):
dividend[] = {1,2,0,9,8,7,5,6,6};
divisor[] = {9,8};
I need the result (dividend/divisor) as:
quotient[] = {1,2,3,4,5,6,7};
I did this using array subtraction:
subtract divisor from dividend until dividend becomes 0 or less than divisor, each time incrementing quotient by 1,
but it takes a...
If I want to sort the second dimension's 0 element like that:
short arr[5];
arr[0][0] = 122;
arr[0][1] = 33;
arr[0][2] = 45;
arr[1][0] = 33;
arr[1][1] = 12;
arr[1][2] = 42;
.
.
.
It will sort arr[i][0], but arr[i][1] and arr[i][2] will come with arr[i][0] to a new element.
...
Hi,
I'm trying to pass JSON array values into my javascript file and use the values as selectors to call methods on corresponding html divs.
for example:
function clickEvents(items) {
for (var r = 0; r < items.length; r++) {
var omega = items[r].id +;
$(omega).click(function() {
alert('Thanks for adding item numb...
Hi,
How can I count the total items in this array below?
Array
(
[upload] => Array
(
[name] => Array
(
[0] => 1024x768.jpg
[1] => 1280x800.jpg
[2] => 1280x1024.jpg
[3] => 1440x900.jpg
)
[t...
Hi,
I would like a function to convert a single dimension array int[480000] into a 2d array of size int[800,600].
Can you please help me how this can be done?
...
I'm generating a multi-dimensional array in javascript that looks like this (this is the JSON representation of the javascript array, it's not in JSON format):
"100": {
"40": {
"subtotal": "24.99",
"turn-around": {
"0": "2-4 Business Days",
"1": "Next Business Day (Add $15.00)"
},
"shipping": {
"...
I have the following code:
...
int n;
cin >> n;
int numbers[n];
...
It compiled with netbeans on mac using g++ (I think) and it didn't compile using vs2008 on windoze. Why is it so hard to make it work with every compiler? The size of the array is known before allocating it.
EDIT: I know abot std::vector. Actually this was part of a...
Sorry for asking a basic question like this but I've been reading on this for a few hours now and the examples aren't making sense to me in context of the way my array is.. I have been able to pass this from my server side (cakephp) to the javascript (I'm using jquery) but after that, I am lost as to how to make use of the data.. I tried...