I have this code that prints out columns in my DB and adds a column "Profit" for me.
Distance is calculated in a complex way and so is done in a loop, while the transformation of distance to "profit" is done as it is printed out.
What I wish to do is print them out in descending order of "profit". I believe (but do not know) that the be...
Should be easy but google couldn't give me a straight answer. I have an array. The fields in the array have underscores that I would like to remove e.g. "Column_1" to "Column 1". Does anyone know a good way to do this without looping through the whole array and rebuilding it anew? I didn't see any methods in the reference that would ...
Is there a "better" way (built-in function, better algorithm) to normalize the case of all the keys in a PHP array? Looping though and creating a new array works
$new = array();
foreach( $old as $key=>$value) {
$key = strToLower($key);
if(!array_key_exists($key,$new) {
$new[$key] = $value;
}
else {
throw new Exception('Duplicat...
I have $_GET['tags'] = "apples, oranges, bananas, grapes, cherries"
I need to place the data into an array ($tags).
What is a quick way to trim each item and perform security functions (stripping html, special chars)?
...
I have two arrays of attributes that describe products in the database:
$sizes = array(
'Shirt Size' => array('Small', 'Medium', 'Large'),
'Sleeve Size' => array('Short', 'Long')
); // Level 1
$colors = array(
'Shirt Color' => array('Black', 'Red'),
'Slee...
I have a method in a class that will append an item to an array member of the class. When the array member is empty (but previously had two items in it at index 1 and index 2) and I call the method, the item is inserted at index 2. Why is that? If anyone doesn't know right off the bat, I can provide MANY more details.
...
I am doing RSA encryption and I have to split my long string into small byte[] and encrypt them. I then combine the arrays and convert to string and write to a secure file.
Then encryption creates byte[128]
I use this the following to combine:
public static byte[] Combine(params byte[][] arrays)
{
byte[] ret = new byte[arrays.Sum(...
The following code does not compile.
int a=1,b=2,c=3;
typedef const int
intlink arr[] = {a,b,c,8};
What C++ standard says about it? Is this compiler error?
P.S. I know I could declare class that contains reference and use it in array, but I really want to know why the code above doesn't compile.
Edit: The following code is...
I have a form that lists module id and also sub_module_id, for example
ADMIN === is parent module ID
users=== sub module id
here admin appears in the menu and users inside admin
now inside the form i have used checkbox like
[]Admin
[]Users
for parent module ID admin
<input id='module_permission[]' onclick=\"selectall()...
Hi,
I have a code a following (simplified version):
#define MESSAGE_SIZE_MAX 1024
#defined MESSAGE_COUNT_MAX 20
class MyClass {
public:
.. some stuff
private:
unsigned char m_messageStorage[MESSAGE_COUNT_MAX*MESSAGE_SIZE_MAX];
};
I don't like defines, which are visible to all users of MyCalss.
How can I do it in C++ style?
...
I have a struct:
struct OutputStore
{
int myINT;
string mySTRING;
}
If I create an array of type OutputStore as follows:
OutputStore *OutputFileData = new OutputStore[100];
then I can address it with:
OutputFileData[5].myINT = 27;
But if I use a vector instead of an array:
vector<OutputStore> *OutputFileData = new vect...
Is there a version of the PHP array class where all the elements must be distinct like, for instance, sets in Python?
...
Hi, I'm trying to create an auto complete field (using the script.aculo.us plugin) in a form for a category select, but I want the auto complete list to display a number next to each category (the number of other things in the same category). This is similar to the Tags field on stack overflow.
Right now I can display the number I wa...
Assuming the @houses array is set up as follows:
house1.price = 10
house2.price = 20
house3.price = 30
@houses << house1
@houses << house2
@houses << house3
This is the starting point of our calculation and we want to find the average price of a house:
total = 0
average = 0
for h in @houses
total += h.price
end
average = total/@hous...
Dear friends,
i have the following XSD:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Persons">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="PersonFullName">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value="[A-Z0-9]{3,50}"/>
</xsd:restriction>
...
Hi guys,
I'm just learning c++ coming from a Java background.
Just playing around with simple classes now, but for some reason the following won't compile, when the same syntax compiles fine elsewhere:
class CardDealer {
private:
string suits[4];
string values[13];
bool cardTaken[4][13];
int getRan...
Hi!
I am working with a one dimensional array in PHP. I would like to detect the presence of duplicate values, then count the number of duplicate values and out put the results. For example, given the following array:
$array = array('apple', 'orange', 'pear', 'banana', 'apple',
'pear', 'kiwi', 'kiwi', 'kiwi');
I would like to pr...
Hi!
I'm using the algorithm described here to fit Gaussian bell curves to my data.
If I generate my data array with:
x=linspace(1.,100.,100)
data= 17*exp(-((x-10)/3)**2)
everything works fine.
But if I read the data from a text file using
file = open("d:\\test7.txt")
arr=[]
data=[]
def column(matrix,i):
return [row[i] for ro...
Hello,
all I want to do, is to fetch the lastest item from my models and
have them in an array sorted (freshest items first) by the attribute "updated_at".
Somewhere is an error, but I can't find it:
@results = Array.new
Note.find(:all, :limit => 3, :order => "created_at DESC").each do |item|
@results << item
end
Pictur...
Hello everybody,
I know that you can easily pass an array to a function, like the code below shows
Private Sub SomeFunction(ByVal PassedArray() As String)
For i As Integer = 0 To PassedArray.Count - 1
Debug.WriteLine(PassedArray(i))
Next
End Sub
Public Sub Test()
Dim MyArray As String() = {"some", "array", "members...