I have following problem with dynamic array be used in sendmany transaction in bitcoin engine, problem described in code comments.

step 1 create array step 2 inserting values to array step 3 print an array to check the result which is correct step 4 sendmany (here is a problem) see below

//step 1 create array
$to = array();
//step 2 inserting values to array
while ( $row_users = mysqli_fetch_array($getting_allowed_users) )
          $to[] = array($row_users['user_bitcoin_wallet'] => $currency);

//step 3 print an array to check the result which is correct

//step 4 sendmany (here is a problem)

// if I do it that way sendmany is only sending to first wallet which is indexed [0]
// I cannot to foreach as php  code structure is not allowing {} inside the command

//Question: How I can display all the values from my array in following place
$bitcoin->sendmany($BuyerAccount,ALL THE VALUES); 


Have you tried: $bitcoin -> sendmany($BuyerAccount, $to);?
Bitcoin API states <fromaccount> {address:amount,...} [minconf=1] [comment] as parameters, so you don't have to iterate - pass the whole array.
If it doesn't work somehow, you can also prepare request by yourself for RPCClient. This is example for sendfrom: $request = '{"method":"sendfrom","params":["'.$params[0].'","'.$params[1].'",'.$params[2].','.$params[3].'],"id":'.$currentId.'}';

| improve this answer | |
  • thank you, array is dynamic and if passed to looks like: array{array{"element1"=>1,"element2"=>1....}} what we need just that middle part "element1"=>1,"element2"=>1 and we cannot call it by number of item from array as we don't know how many we may have.... what it works is $to[0] or $to[1] ..etc on it's own... – user2511459 Nov 16 '13 at 12:36

I am actually working on trying to figure out the same thing, but from my understanding is you are looking to have it repeat? Try something like this.

$to = array();
$count = 0;

while ( $row_users = mysqli_fetch_array($getting_allowed_users) )
          $to[$count++] = array($row_users['user_bitcoin_wallet'] => $currency);

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.