hitman.star hitman.star - 5 months ago 18
Vb.net Question

How to send and recieve array data from Visual Basic to PHP?

I have a vb.net application where i am sending error string to a php page to process it.

Look at this:
How to send and recieve data from Visual Basic to PHP?

But now, I want to send and recieve array data from Visual Basic to PHP.

Well, if the errorString is like this array:

Dim errorString As String = new String(2) {}
errorString(0) = "Hello"
errorString(1) = "World!" ,


how can I send this errorString?

Anyone help me!

Answer

Assuming you're folllowing the example in the link you gave above, this should work:

Dim errorString = "errorString[0]=Hello&errorString[1]=World"

...

Dim byteArray As Byte() = Encoding.UTF8.GetBytes(errorString)

Obviously if you want to do this programatically, where you don't know the contents of the array in advance, then you might have to do a loop through the array to build up the string one field at a time.

On the PHP side, you should then be able to do (for example):

foreach ($_POST['errorString'] as $key => $value) {
echo $value . "<br />";
}

This will allow you to access all the fields in the errorString array.