I've got a list of names separated by commas (they may contain other characters), or be empty, but generally looking like this:
NameA,NameB,NameC
I need to create a function to delete a name if its present in the list and which restores the comma separated structure.
eg: if NameA is to be deleted, I should end up with:
NameB,NameC
...
Hi everybody,
I have the following php loop that takes an array that contains a set of arrays, then I convert each array to a list to manipulate more accurately the elements.
while ($i<sizeof($my_array)){
while(list($key,$val) = each($my_array[$i])){
$j = $i+1;
if ($key == "fruit"){
$val = "ananas".$j;
...
Are there macros or builtins that can return the length of arrays at compile time in GCC?
For example:
int array[10];
For which:
sizeof(array) == 40
???(array) == 10
Update0
I might just point out that doing this in C++ is trivial. One can build a template that returns the number inside []. I was certain that I'd once found a len...
Hi,
I'm currently working on a webshop. For that i need to make a two dimensional array to store the items moved to the cart.
Cart:
Cart = Session("Cart")
Items = Session("Items")
And when an item is moved to the cart:
Items = Items + 1
Cart(1,Items) = Items
Cart(2,Items) = rs("id")
Cart(3,Items) = Request("attr")
Cart(4,Items) = ...
Here's the problem:
I have words I entered via a textarea. I put each word in an entry. i.e words are in an array. On the other hand, I got a wordlist, in which words are separated by newline, I put each word in another array, too.
Now I want to check if $words_entered[$i] = any (and which) of the array $wordlist.
Thanks in advance!
...
How can I check if any of the strings in an array exists in another string?
Like:
a = ['a', 'b', 'c']
str = "a123"
if a in str:
print "some of the strings found in str"
else:
print "no strings found in str"
That code doesn't work, it's just to show what I want to achieve.
...
I have a string array or arraylist that is passed to my program in C#. Here is some examples of what those strings contain:
"Spr 2009"
"Sum 2006"
"Fall 2010"
"Fall 2007"
I want to be able to sort this array by the year and then the season. Is there a way to write a sorting function to tell it to sort by the year then the season. I k...
Hi,
I was wondering if there's a way to get the length of a second-level array, for example :
var arr = new Array();
arr[0] = new Array();
arr[0][0] = 'a';
arr[0][1] = 'a';
arr[0][2] = 'a';
I tried this, but without success :
arr[0].length;
Cheers!
EDIT
The evil code is as follows.
This is the function that I use to fill the a...
I am building a page which allows our members to select their notification preferences based on a number of options. For example sake, I am giving the option for the member to select notifications when a new message arrives and when an update has occured. They can receive the notification via email, sms, both, or neither.
If I simply bu...
Hello!
Code inside Function is working, but as i want to process more then one Url i wanted to make it a function using a array to get the urls to process. Here is the Code:
<?php
$site = array("http://www.ihr-apotheker.de/cs1.html", "http://www.ihr-apotheker.de/cs2.html", "http://www.ihr-apotheker.de/cs3.html");
fu...
On a PHP site using the smarty template engine (or at least a close relative of smarty), I am calling a template include file ("header.html") which contains this code excerpt, along with other HTML omitted here for clarity:
<title>{$title|escape:"html"}</title>
{if isset($META) && $META}
{foreach from=$META item=m}
<meta nam...
im trying to merge two arrays together. both have numeric keys and are unique. when i use array_merge, it re-indexes starting at 0.
so lets say i have
[2] = abc
[5] = cde
and i have
[32] = fge
[13] = def
i want to merge these two together maintaining the unique keys.
below is the explaination on the current merge behavior.. an...
I have two arrays of pointers to doubles that I need to swap. Rather than just copy the data within the arrays, it would be more efficient just to swap the pointers to the arrays. I was always under the impression that array names were essentially just pointers, but the following code receives a compiler error:
double left[] = {1,2,3};
...
I have an array "$abc" which has 9 elements, as:-
Array
(
[a] => Jack
[b] => went
[c] => up
[d] => the
[e] => hill
[f] => but
[g] => never
[h] => came
[i] => back
)
Now I need to concat only the 4 elements starting from the "b" index to the "e" index only. But I don't know what to do. I used the "im...
I have some library of classes, working with my data, which is being read into buffer. Is it possible somehow to avoid copying arrays again and again, passing parts of data deeper and deeper into processing methods? Well, it sounds strange, but in my particular case, there's a special writer, which divides data into blocks and writes the...
Normally, if I want to pass arguments from $myarray to $somefunction I can do this in php using
call_user_func_array($somefunction, $myarray);
However this does not work when the function one wishes to call is the constructor for an object. For fairly obvious reasons it does not work to do:
$myobj = new call_user_func_array($classna...
I have an JavaScript object like this:
id="1";
name = "serdar";
and I have an Array which contains many objects of above. How can I remove an object from that array such as like that:
obj[1].remove();
...
Hello,
I have the following line in my code:
object[] inputs = new object[] {"input1", "input2", "input3", "input4"};
I would like to know how (without knowing how many elements will be in the array) add dynamically using a loop like this:
object[] inputs;
foreach (string key in Request.Form.Keys)
{
inputs[0] = key;
}
How co...
Well guys i've been struggling with this for about 5 hours now and i realise my brain is fried thought i better get some people who know what they are doing :p Now i just have to explain the problem properly.
I want to display all the goal scorers with just their name and goal time for each separate goal after it like:
Carlton Dickson ...
I have two arrays. The first one looks like:
Array1
(
[14] => foo
[15] => bar
[16] => hello
}
and the sencond looks like:
Array2
(
[Label1] => foo
[Label2] => bar
[Label3] => hello
[Label4] => foo
[Label5] => bar
}
I would like to compare the values of array1 against array2, if they match, I would like to re...