Hi,
I am sending a reference of an array variable which is initially empty.
In the called function the array gets populated.
function one()
{
$ret = array();
two($ret);
pri nt_r($ret);
}
function two(&$res)
{
foreach($a as $b)
{
$id = $b->getid();
$txt = $b->gettxt();
$res[$id] = $txt;
...
//check which faction members are online
$sql = mysql_query("SELECT * FROM ".TBL_ACTIVE_USERS."
WHERE faction=$userfaction_id ORDER BY timestamp DESC,username");
//no '' around var as it is an integer, so php doesn't expeect it to be string
$numrows = mysql_numrows($sql);//gets number of members online
if($numrows == 1){ echo 'You are t...
I have a simple constant called "subjects" in my model Inquire.rb and I like to know if there is a simple way to use the position in the Ruby array rather than making a hash from it with ids or some more complicated array.
Can I do this?
i.e. instead of to_s as it currently does for the value in the select, I would want an integer indi...
Given a list (length = n) of 2x2 matrices, how do I calculate the sum of all those matrices (and get a 2x2 matrix) ?
How can I do it, if instead of a list I have those matrices in a (2 x 2 x n) dimensional array ?
...
Suppose I have a sorted array of integers int[], and I want to search the closest smaller value to some input number.
for example if the array contains (1) , (23), (57) , (59), (120) and the input is 109, the output should be 59.
I am just trying to see suggestions and compare to the approaches I already have.
...
I need to check if some integer value is already in my database (which is growing all the time). And it should be done several thousand times in one script. I'm considering two alternatives:
Read all those numbers from MySQL database into PHP array and every time I need to check it, use in_array function.
Every time I need to check the...
So this is an example:
Array (
[0] => Array ( [title] => Title_1 [checkout] => 1 [no_gateway] => 0 )
[1] => Array ( [title] => Title_2 [checkout] => 1 [no_gateway] => 1 )
[2] => Array ( [title] => Title_3 [checkout] => 0 [no_gateway] => 0 )
[3] => Array ( [title] => Title_4 [checkout] => 1 [no_gateway] => 1 )
[4] => Array ( [title] =>...
I want to send an array from main.html to test.php file and receive an other array from test.php , but it does not work.plz help me!
main.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Unti...
I have an array which i use to dynamically create a table.
I have a name=value pair (Server=server.alias) which values are being extracted and would like to make it hyperlinked to another webpage.
What I need help is figuring out the code to map the alias name with a specific href link which I think I will have to hard code. The href li...
I am trying to set lower limit and upper limit for an array. The lower limit is always constant, which is 0 but i want the upper limit to be varying based on the array values.
some times the array values are 1,2,3,4,5 and sometimes the array values are 100,200,300,400,500 and sometimes in thousands as well. So i do not want to set a co...
Please forgive me, but I do know js basics and how to write/call a basic function, but in this case I'm trying to match an alpha sorted list of categories from the DB to match against my set (non-alpha) order of said categories as specified below (this is code suggested for use by another user on a question I asked about how to map the o...
hey guys, when i run:
with open('file00.txt') as f00:
for line in f00:
farr=array.append(float(line))
print "farr= ",farr
i get:
farr=array.append(float(line))
AttributeError: 'module' object has no attribute 'append'
does anyone know why I get this? do I have to import something? am I doing it compl...
The objective is to build a "infinite" tree using dynamic arrays.
items[3]
- MENUITEM
- items[2]
- MENUITEM
-items[0]
- MENUITEM
- items[0]
- MENUITEM
- items[0]
- MENUITEM
- items[2]
- MENUITEM
- items[0]
- MENUITEM
- items[0]
I define the structure:
typedef struct MENUITEM {
char id...
How would I make an associative array (or some comparable alternative) in jQuery AND send that array via ajax to a php page so that I can use php to handle it?
Something like this...
// jQuery
if($something == true) {
data[alt] = $(this).attr('alt');
data[src] = $(this).attr('src');
else if ($something == "something else") {
...
how would one go about finding the minimum value in an array of 100 floats in python?
I have tried minindex=darr.argmin() and print darr[minindex] with import numpy (darr is the name of the array)
but i get:
minindex=darr.argmin()
AttributeError: 'list' object has no attribute 'argmin'
what might be the problem? is there a better alte...
Hey guys, how would you erase a whole array, as in it has no items. I want to do this so I could store new values (a new set of 100 floats) into it and find the minimum.
Right now my program is reading the minimum from sets before I think because it is appending itself with the previous set still in there (i use .append by the way).
...
hey guys, this is very confusing...
i am trying to find the minimum of an array by:
for xpre in range(100): #used pre because I am using vapor pressures with some x molarity
xvalue=xarray[xpre]
for ppre in range(100): #same as xpre but vapor pressures for pure water, p
pvalue=parray[p]
d=math...
Hello,
Can i decode and encode an array in ths way??
NSMutableArray *arr;
-(void)encodeWithCoder:(NSCoder*)coder
{
[coder encodeInt:arr forKey:@"Array"];
}
-(id)initWithCoder:(NSCoder*)decoder
{
NSMutableArray array;
array = [[decoder decodeIntForKey:@"Array"]copy];
return self;
}
...
Is
var myCars=new Array("Saab","Volvo","BMW");
and
var myCars=["Saab","Volvo","BMW"];
exactly the same ?
...
Hello,
I would like the value that has an o in the following example to be added to the key before the first key that has a value with an o in the array. Like this:
$arr = array(
0 => 'apple',
1 => 'pear',
2 => 'orange',
3 => 'octopus',
4 => 'pineapple'
)
$arr = array(
0 => 'apple',
1 => 'pearorangeoctopus',
2 => 'Pineapple'
)
But ...