arrays

PHP Array filter regular expressions

Hi all i have an array shown below Array ( [0] => http://api.tweetmeme.com/imagebutton.gif?url=http://mashable.com/2010/09/25/trailmeme/ [1] => http://cdn.mashable.com/wp-content/plugins/wp-digg-this/i/gbuzz-feed.png [2] => http://mashable.com/wp-content/plugins/wp-digg-this/i/fb.jpg [3] => http://mashable.com/wp-cont...

Search and remove from multidimensional array

If I a value ID equals 1 and search an array I like to remove from the array itself where ID is 1 if found. Array ( [0] => Array ( [id] => 1 ) [1] => Array ( [id] => 4 ) [2] => Array ( [id] => 5 ) [3] => Array ( [id] => 7 ) ) new array Array ( [0] => Array ( ...

Visual Basic 2010 Creating a Control Array

How can I make a control array? Or the equivalent. I am used to Visual Basic 6 which presents the option of whether to create a control array when I copy and paste and control. ...

Access array in PHP ojbect

Hi, I have the following PHP object but I'm struggling to get the array item out of the object. exampleBatch Object ( [file_path:protected] => [title:protected] => [description:protected] => [link:protected] => [items:protected] => Array ( ) [raw:protected] => data/example [feed_nid:protected] => Array ( [0] => Array ( [path...

ifstream random integers?

I have been trying to read in integers from a file do some operations and output them to another file. When I input the integers into an array and then print out the result of come up with random numbers. Is this something to do with ifstream that I don't understand or am I missing something obvious? #include<iostream> #include<fstream>...

How to find the largest and smallest number in an array in c

I have to find a way to display the Maximum and Minium number in an array, the size of the array is 100 and will not exceed that and there is not need for input validation. The program will keep asking for input until 0 is encountered and it too will get added to the array. I have everything figured out except how to keep track which is...

counting non-zero elements within each row and within each column of a 2D numpy array

I have a numpy matrix that contains mostly nonzero values, but that occasionally will contain a zero value. I need to be able to: 1.) count the non-zero values in each row, and put that count into a variable that I can use in subsequent operations, perhaps by iterating through row indices and performing the calculations during the itera...

php array insert new item in any position

how can i add new item to array? for example in the middle of array? ...

PHP: Make first letter capital in list?

As i have this: $full_name = $data['full_name']; list($firstname, $lastname) = explode(' ', $_POST['full_name']); (after this comes a query where it inserts $lastname and $firstname) Where should i use ucfirst() ? Should i just make new variables again? $newfirstname = ucfirst($firstname); $newlastname = ucfirst($lastname); or ca...

c++ initialize array in constructor without using default constructor or assinment

Consider: struct A { A (int); A (const A &); }; struct B { A foo [2]; B (const A & x, const A & y) : foo {x, y} /* HERE IS THE PROBLEM */ {} }; I was expecting this to work since I'm using C++0x support in GCC4.3, which allegedly supports initialiser lists. No joy. I have a class A which has no default constructor. This is...

Is there a simpler way of printing a PHP array in a string?

Hi All As you know, a good programmer is a lazy programmer, but I'm just lazy. My question is this: Is there a simpler way to print out an element of an array (from a MySQL query) in a PHP echo statement? I usually do this: echo "string start " . $array['element'] . " string end"; It works FINE, I'd just like a shorter way of printi...

How to insert an element in any position in php

hi guys, I am with an array like $x = array(1,2,3,4,5); i would like to add element 6 in between 3 and 4 and make it like array(1,2,3,6,4,5); how do i make it in that place or first place? ...

max length size for define a new array

Possible Duplicate: What is the Maximum Size that an Array can hold? i want to define new array for example: string[] str=new string[maxsize]; now the maximum number that i can set for maxsize is what? ...

Select parts of a string till a certain character and store in an array

Hi Guys, I am trying to select parts of a string till a certain character, -----, and put them in an array. For eg. in the below paragraph I want to store from "Game..the", "next....player", "free....zone" and "or....career" in one array in php. Gamers can also take on Blitz a wild, high-pressure challenge where players must race agai...

Beginners Java Array Question

I'm trying to output a square of X's using an array. The diagonals of the square will be filled with 'X' and the empties will be filled with spaces '_'. Here's the code I got: public static char[][] square(int z) { int size=5; char[][] myArr = new char[size][size]; for (int c=0;c<size;c++) myArr[c][c]='X'; for ...

Java Array Question

I'm trying to create a triangle where empty cells have spaces and non empty cells have X's. public static char[][] Triangle(int size) { char[][] triangle = new char[size][size]; for (int i = 0; i < size; i++) { Arrays.fill(triangle[i], '_'); } for (int rows = 0; rows < size; rows++) { for (int ...

How can I store a YAML object in Memcached ? Without a serializations problems.

I'm using gem 'dalli' but the same problem happen with gem memcached-client development.rb config.cache_store = :dalli_store My app controller Rails.cache.write('presidentes', Candidato.by_cargo(:key => "Presidente")) @presidentes = Rails.cache.read('presidentes') If I debug the @presidentes var it returns --- !binary | BAhvOi...

get last value in array

I have an array like this: [33] => Array ( [time] => 1285571561 [user] => test0 ) [34] => Array ( [time] => 1285571659 [user] => test1 ) [35] => Array ( [time] => 1285571682 [user] => test2 ) How i can get the last value in the array, but maintaining the index [...

Looping over ul li's using jQuery and storing current nav item

Hi, I am looping over the first set of li a tags in my UL and getting the height so that I can deliver a different background image if the a > span > span text wraps across two or three lines. I need to be able to store these specific buttons in an array, so that when I mouse over them, the current span with double line text receives a...

PHP array sort using inner val

Hi, I have this array : Array ( [1] => Array ( [id] => 1 [sort] => 1 ) [3] => Array ( [id] => 3 [sort] => 3 ) [2] => Array ( [id] => 2 [sort] => 2 ) ) How do i sort it so its re-ordered using the inner 'sort' key ? ie the above would look like this: Array ( [1...