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

CC BY-SA 3.0
2013-11-16T12:36:32.040Z
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
CC BY-SA 3.0
2013-11-16T12:30:08.730Z
2013-11-16T12:30:08.730Z
ripazha
<p>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.</p>

<pre>
$to = array();
$count = 0;

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

</pre>

CC BY-SA 3.0
2015-12-20T20:08:34.477Z
2015-12-20T20:08:34.477Z
Ryan Mcphee
<p>I have following problem with dynamic array be used in sendmany transaction in bitcoin engine, problem described in code comments.</p>

<p>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</p>

<pre><code>&lt;?php
//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'] =&gt; $currency);
}

//step 3 print an array to check the result which is correct
print_r(array_values($to)); 

//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
$bitcoin-&gt;sendmany($BuyerAccount,$to[0]); 

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

//example
$bitcoin-&gt;sendmany($BuyerAccount,"walet1"=&gt;0.1,"walet2"=&gt;0.1,"walet3"=&gt;0.1.....);
?&gt;
</code></pre>

<bitcoind><php>
Dynamic PHP Array used in sendmany bitcoin command issue
user2511459
# Dynamic PHP Array used in sendmany bitcoin command issue

(Asked by: username_0 on 2013-11-16)

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

```
<?php
//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
print_r(array_values($to)); 

//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
$bitcoin->sendmany($BuyerAccount,$to[0]); 

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

//example
$bitcoin->sendmany($BuyerAccount,"walet1"=>0.1,"walet2"=>0.1,"walet3"=>0.1.....);
?>

```

**Tags:** bitcoind, php


---

## 2 answers

### Answer by username_1 on 2013-11-16. Score: 1

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.'}';`

> **Comments:**
> **username_0**: 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...  

---

### Answer by username_2 on 2015-12-20. Score: 0

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);
}

```


---

