473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

please help - can array hold more same key names (with differentvalues)?

Hi php gurus,

I need to create an array which will contain more keys with same name,
but of different values. I have no idea how to do it. Could you please
help me?

This is what I'd like to do:

$postdata=array("senderid"=>"1111", "senderpass"=>"blah",
"userfile[]"=>"@newclients.csv", "userfile[]"=>"@invoices.csv");

But userfile[] will be stored in that array only once, so I cannot use
it to feed libcurl for automated file upload :(

Is this possible to handle somehow in php? It think it is either trivial
or impossible, but i'm clueless at this point :( (If that's trivial,
please try to be patient and don't kill me for stupid question :) )

Thank you in advance,
Y.

Here's more info for those who are interested why do I need it:

The $postdata will be posted by curl to the page which looks almost
exactly like copied from PHP help:

<form action="file-upload.php" method="post" enctype="multipart/form-data">
<input name="senderid" value="1111" type="hidden">
<input name="senderpass" value="blah" type="hidden">
clients:<br>
<input name="userfile[]" type="file"><br>
invoices:<br>
<input name="userfile[]" type="file"><br>
<input type="submit" value="Send files">
</form>

I initialize curl and upload (this works fine, but i need to upload both
files at once, and i cannot set them with single pass)

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $submitlink);
curl_setopt ($ch, CURLOPT_VERBOSE, 0);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_exec($ch);

Best would be if I could convince the author of that webpage to use
<input name="userfile1" type="file"><br>
<input name="userfile2" type="file"><br>
and then it would work fine, but that's what I can't :(
Nov 24 '05 #1
2 1732

$postdata=array("senderid"=>"1111", "senderpass"=>"blah",
"userfile"=>array("@newclients.csv","@invoices.csv "));

echo $postdata["userfile"][0];

Nov 24 '05 #2
On 24.11.2005 14:22, Ian B wrote:
$postdata=array("senderid"=>"1111", "senderpass"=>"blah",
"userfile"=>array("@newclients.csv","@invoices.csv "));

echo $postdata["userfile"][0];


Whoa, it couldn't have been easier :)
Many thanks dear Ian :D

Y.
Nov 25 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: billy | last post by:
I've got a set of subclasses that each derive from a common base class. What I'd like to do is create a global array of the class types (or, class names) that a manager class can walk through in...
35
by: VK | last post by:
Whatever you wanted to know about it but always were affraid to ask. <http://www.geocities.com/schools_ring/ArrayAndHash.html>
38
by: VK | last post by:
Hello, In my object I have getDirectory() method which returns 2-dimentional array (or an imitation of 2-dimentional array using two JavaScript objects with auto-handled length property - please...
39
by: gtippery | last post by:
Newbie-ish questions - I've been away from C for a _long_ time. It seems to me that there ought to be easier (or at least shorter) ways to do what this does. It does compile & run for me (with...
3
by: s.subbarayan | last post by:
Dear all, I encountered the following piece of program: #include <stdio.h> void strprint(char *str); void main() { char *spr="hello"; strprint(spr); }
6
by: Yanhao Zhu | last post by:
Hi, all, If I have an array like int m = new int { 0, 1, 2, 3 }, is there a way I can separate the array into two, like int m01 = somefunction?(m,0,2) // m01 will hold 1st and 2nd items in...
1
by: Mark Hollander | last post by:
Hi All, Could you please help me convert this code so that it will run in VB.NET Thank You Mark Hollander Private Type USER_INFO Name As String
22
by: howachen | last post by:
which one is recommend? seems they perform the same thing... regards, howa
2
by: yeshello54 | last post by:
so here is my problem...in a contact manager i am trying to complete i have ran into an error..we have lots of code because we have some from class which we can use...anyways i keep getting an error...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.