arrays

Receive all values for input[] in array form in jQuery to send to PHP script

Hi there I am busy getting values on a form using jQuery to send to my PHP script. Well, most of my checkboxes have a name in the form of name="input[]" and so when I alert the value that gets returned in my form's submit() handler, it only returns the value of the first checkbox with that name. How can I return the values in array form...

Null pointer when moving data around

Hey Guys, I've got a function filling a HashMap(rMap) of String arrays. Once certain conditions are met e.g r.Map.size() != 0 I then, in another file (rMap is a Global variable) call the following String array[] = rMap.get(0) from this I attempt to System.out.println(array[0]) . Thats the run of the program and I get a null pointer at ...

php string variable containing as input for array function

Why this does not work? $stringhaha =" 1 => General, 2 => Business, 3 => Entertainment, 4 => Health, 5 => Politics, 6 => Sci/Tech, 7 => Sports, 8 => News"; $all_categories = array($stringhaha); print_r($all_categories); (will give an array with 1 item.) While this works: If I include ...

extract first 3 items in an array

$array = array('item1', 'item2', 'item3', 'item4', 'item5'); here i want to extract only the first three items in the array, and then $implodes = implode(';', $array); echo $implodes; which should output item1;item2;item3 $i=0; $new = array(); foreach($array as $arr) { $i++; if($i <= 3) { $new[] = $arr; } } doesn't ...

php 4 variable variables

Hi, $str='input_arr["username"]'; $input_arr=array(); $$str='abcd'; print_r($input_arr); When I run the above code it only prints Array(). I expected it to print Array([username]=>'abcd') What am I doing wrong? This is in php 4 by the way. Thanks a lot. Edit:What am I trying to do? $input_arr is supposed to be a static variabl...

How to determine the amount of entries an array has?

I'm trying to loop through an array backwards, so I figured I could try $Array = Array("One", "Two", "Three", "Four", "Five"); For ($Entry = Amount_of_values($Array); $Entry = 0; $Entry = $Entry-1){ Echo $Array[$Entry] . " "; //Should be Five Four Three Two One } but I have no idea how to retrieve the amount of values in an array ...

Add Additional Objects to JSON Encoded Array

Hi, I am currently using a JSON encoded array to display the users in my database for an auto-suggest feature. It looks something like this: $sth = mysql_query("SELECT id, name FROM users"); $json = array(); while($row = mysql_fetch_assoc($sth)) { $json['name'] = $row['name']; $json['id'] = $row['id']; $...

perl - how do you extract all elements of an array except the last?

I need to extract all elements in an array except the last and store them in a scalar for later use. At first, I thought this would be possible using array slices, but it appears that you cannot count backwards. For example: my $foo = ($bar[0..-2]); or my $foo = ($bar[-2..0]); Any help would be greatly appreciated as this i...

Get a subset of random values from an array php

Hi, Starting with an array with 10K values. I want to randomly get 1000 values from it and put them into another array. Right now, I am using a for loop to get the values, but I want to pick 1000 values and not have to loop 1000 times. The array_slice function works, but it doesn't give random values. What is the correct (most effi...

recursive function php

I have an array which looks like this $dataArray = array ( 0 => array ( 'UserId' => '804023', 'ProjectCode' => 'RA1234', 'Role' => 'PI', ), 1 => array ( 'UserId' => '804023', 'ProjectCode' => 'RA1234', 'Role' => 'PM', ), 2 => array ( 'UserId' => '804023', 'ProjectCode' => 'A90123', ...

PHP: Can an array have an array as a key in a key-value pair?

I'm getting an "Illegal offset type" for this array: public static $CATS_AND_TYPES = array( // Statement Administration array( self::CAT_STATEMENT_ADMIN => "Document Administration" ) => array( self::TYPE_STATEMENTS_LOADED => "Documents Loaded", self::TYPE_STATEMENTS_REMOVED => "Documents Removed...

Java weird array behavior

Why is it that this works: int[] array = {1, 2, 3}; but this doesn't: int[] array; array = {1, 2, 3}; If I have an array instance variable and I want to initialize it in my constructor surely I don't have to go array = new int[3]; array[0] = 1; array[1] = 2; array[2] = 3; I feel like I'm missing something here? ...

PHP/mysql: querying MySQL with an array and getting results in an array

I have an array, $scans. I want to query MySQL with all the values in that array and get my results back in an array. For example, sample data in scans would be: E1234 E2244 E3654 The MYSQL table PARTS has fields part, size, length, plate, side, type. I want to end up with $output["E1234"][0] to be the size result for that part, 1 t...

After upgrading from VS 2008 to VS 2010, getting Contains is not a member of system.array error

I have a website I developed in VS 2008 targeting .net 3.5. It has worked well. I recently upgraded to VS 2010 and needed to make a few changes to the site. However, I'm receiving compile errors (haven't made any changes to the code yet--was just launching the site to make sure it worked ok). I get "Contains" is not a member of syste...

Array diff of specific key within multi-dimensional array

I have two arrays of products, both formatted exactly the same, like so: $products = array( [0] => array( ['product_id'] => 33 ['variation_id'] => 0 ['product_price'] => 500.00 ), [1] => array( ['product_id'] => 48 ['variation_id'] => 0 ['product_price'] => 600.00 ), ) I ...

Search an array for a matching string

Hi There, I am looking for away to check if a string exists as an array value in an array is that possible and how would I do it with PHP? ...

How to fire a event for Array push? [Flash]

How would I go about as to addEventListener for a array object. I'm trying to avoid running a timer every x milliseconds to check for new elements in array object, rather trying to make a event fire when new elements are detected to process them and remove them. Is it possible with Arrays? maybe ArrayCollections? either is fine. P.S.>...

vb.net in InDesign Scripting - Grouping TextFrames

I want to group textframes in my InDesign CS3 vb.net script. It worked for InDesign 2.0 but it does not work with InDesign CS3. Here is my code: Dim myDoc As InDesign.Document = Nothing Dim myGroup As InDesign.Group = Nothing Dim myObjectList(2) myObjectList.SetValue(myOuterTextFrame, 0) myObjectList.SetValue(myInnerTextFrame, 1) myObj...

Print the keys of an array

I could not figure out how to pass a variable number of variables into a function. I thought passing in an array and using the array keys for the variables names could replace the need to pass extra variables into the function, and it worked (I'm sure there is a better way to accomplish this, suggestions welcome). However, I can't seem t...

Getting unique values from 2 arrays

I have 2 arrays that I'm trying to get the unique values only from them. So I'm not just trying to remove duplicates, I'm actually trying to remove both duplicates. So if I'm getting the 2 arrays like this: $array1 = array(); $array2 = array(); foreach($values1 as $value1){ //output: $array1 = 10, 15, 20, 25; $array1[] = $value1; ...