arrays

PHP/Mysql array_pop missing first value

Basically what happens is this: A person goes to a specific gallery, say GalleryID=42. I do a query to grab all of the images in that gallery (with the value of GalleryID=42), and do a separate query to grab all of the comments associated with that gallery (for example GalleryID=42). There may only be 4 comments total on 3 different p...

how to get values of array out

I have this array $pv->orderRecordsArray = array(); foreach($order->records as $i=>$orderRecord){ $pv->orderRecordsArray[] = $orderRecord->orderRecordID; } // print_r($pv->orderRecordsArray) for example // shows Array ( [0] => 46839 [1] => 46840 [2] => 46841 ) I need to use the array values from above in my sql statemen...

How do I concatenate arrays of aliases in Perl?

How do you concatenate arrays of aliases in Perl such that the resulting array also contains aliases? The solution that I came up with is: my ($x, $y, $z) = 1 .. 3; my $a1 = sub {\@_}->($x); my $a2 = sub {\@_}->($y, $z); my $a3 = sub {\@_}->(@$a1, @$a2); say "@$a3"; # 1 2 3 $_++ for $x, $y, $z; say "@$a3"; # 2 3 4 What I am n...

How do you split a string into word pairs [php]?

I am trying to split a string into an array of word pairs in PHP. So for example if you have the input string: "split this string into word pairs please" the output array should look like Array ( [0] => split this [1] => this string [2] => string into [3] => into word [4] => word pairs [5] => pairs please ...

Compare two string ArrayLists

I have two array lists dim Colors1 = New ArrayList Colors1.Add("Blue") Colors1.Add("Red") Colors1.Add("Yellow") Colors1.Add("Green") Colors1.Add("Purple") dim Colors2 = New ArrayList Colors2.Add("Blue") Colors2.Add("Green") Colors2.Add("Yellow") I would like to find out which colors are missing from Colors2 that a...

Parsing javascript arrays in PHP

I can't seem to figure out how to get a JS array into PHP. What I have to work with looks like this: var arrLow = [ { "e": "495864", "rank": "8678591", "rankmove": "<p><img src='up.php?uStyle=144'> UP 495864" }, { "e": "104956", "rank": "-", "rankmove": "<p><img src='up.php?uStyle=145'> DOWN 1" }, { "e": "0", "rank": "0", "rankmove": "...

Java Array Manipulation

Ok so I have a function named resize, which takes a source array, and resizes to new widths and height. The method I'm using, I think, is inefficient. I heard there's a better way to do it. Anyway, the code below works when scale is an int. However, there's a second function called half, where it uses resize to shrink an image in half. S...

Symfony : error while accessing an array

Hello, i want to output an array containing numbers. I'm creating the array like this (it recieved the statistics for the last 7 days) : <?php public function getStatisticsTeams() { $tab = array(); for($i=7;$i=0;$i--) { $q = Doctrine_Query::create() ->from('stJob j') ->where('j.created_at = ?', date('Y-m-d h:i:s...

C++ Struct in array, help!

Hello - I have an iPhone app that used to use an array of several thousand small objects for its data source. Now, I am trying to make it use C++ Structs, to improve performance. I have written the struct, and put it in "Particle.h": typedef struct{ double changeX; double changeY; double x; double y; }ParticleStruct; The...

PHP Function that returns an array of values of keys

Hello all I have an array like this... Array ( [0] => Array ( [id] => 10651 [userid] => 079eb9f4b9eb573f6aec93ce97ed1e7f ) [1] => Array ( [id] => 74315 [userid] => 1283612836 ) [2] => Array ( [id] => 74315 ...

Puzzle : finding out repeated element in an Array

Size of an array is n.All elements in the array are distinct in the range of [0 , n-1] except two elements.Find out repeated element without using extra temporary array with constant time complexity. I tried with o(n) like this. a[]={1,0,0,2,3}; b[]={-1,-1,-1,-1,-1}; i=0; int required; while(i<n) { b[a[i]]+...

C++: Modifying array values for const

Hi, Consider the following: int a[2]; cin >> a[0] >> a[1]; const int D = a[1] - a[0]; cout << D << "\n"; a[1] = 5; a[0] = 2; cout << D << "\n"; I'm a bit confused now. Why does it print the same value for D? Why doesn't changing the array values change the value of D? At what point in time is the value of D determined and stored?...

PHP uksort() for several arrays

I would like to have a unique sort function for several associative arrays. The best candidate among the various PHP sort functions would be uksort(), (usort() would be ideal, but it changes the array keys to become the numerical index(!)). For instance (using a simpler array) function sorting_by_length_desc ($a, $b) { return...

"Can't use function return value in write context" error in PHP

Fatal error: Can't use function return value in write context in line 3, In which cases such errors get triggered? My program: //QUERY VARIABLE $query="select * form user where user_name='$user_name' and user_password='sha($user_password)'"; //ESTABLISHING CONNECTION $result=mysqli_query($dbc,$query)or die('Error Query...

2D Arrays and Pointers - C

Hi there, Just trying to really get my head round Arrays and Pointers in C and the differences between them and am having some trouble with 2d arrays. For the normal 1D array this is what I have learned: char arr[] = "String constant"; creates an array of chars and the variable arr will always represent the memory created when it wa...

How do I create this multidemsional Array, Hash Combo?

I have this data and i need an output like this type of output.. I basically need to have all the venues and their dates and all the songs associated to them ....if anyone can think of a better structure and how to achieve it I would be very thankful... { ["Vector Arena - Auckland Central, New Zealand" => { "2010-10-10" => ["...

Simple "find element in array and return value" function in php

I have a value like this: $id = $_GET['id']; I need to compare this value to an array which converts this value into another value. For example, if id==14, then check array for element 14, and return its value, for example in this case "Cars". Anybody know a simple code for this? Thanks ...

PHP Arrays Accessing title name of array object

Hi, I am trying to get the title name of an array object. For example I have $results[0]['page'] $results[0]['title'] I was wondering if I could use a for loop to loop through the $results[0] array and get the 'page' and 'title' names and insert them into a new array? Thanks for your time ...

Using array values as another array keys

Good day everyone. I have an regular array (this is the print_r result, the array can have from 1 to n positions): Array ( [1] => value1 [2] => value2 [3] => value3 ) I have another array defined elsewhere as: $array_def['value1']['value2']['value3'] = array( 'fl' => 'field1', 'f2' => 'field2', ); Using the first arr...

Sorting array of type of object respecting to one of the object values

i have a class called student, the class have two elements (Name, ID). in my main class, i have created about 10 students in an array i called it students, now i want to sort the the students array respecting the ID, or the name!! if i used this line of code array.sort(students); is there a way to use the sort method and choose whi...