sendmany bitcoin command problem in Dynamic PHP array

0 votes

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,"walet2"=>0.1.....);
Aug 31, 2018 in Blockchain by digger
• 26,740 points
997 views

2 answers to this question.

0 votes

You're bulding the $to array in the wrong way. You need a key-value pairs array, you can build it up this way:

$to[$row_users['user_bitcoin_wallet']] = $currency;

Then you can call sendmany this way:

$bitcoin->sendmany($BuyerAccount,$to);

Your code became:

<?php
//step 1 create array
$to = array();

//step 2 inserting values to array
while ( $row_users = mysqli_fetch_array($getting_allowed_users) )
{
          $to[$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

$bitcoin->sendmany($BuyerAccount,$to); 
answered Aug 31, 2018 by slayer
• 29,370 points
0 votes

You might consider spliiting that array up as too many in one request can be a bit much for the bitcoin daemon.

$chunks=array_chunk($to,100,true);
forach($chunks as $row) $bitcoin->sendmany($BuyerAccount,$row);
answered Sep 3, 2018 by Tenneb

Related Questions In Blockchain

0 votes
1 answer

How to use bitcoin price as place holder in php?

You can do it by providing an ...READ MORE

answered Aug 21, 2018 in Blockchain by digger
• 26,740 points
972 views
0 votes
1 answer

How to create Bitcoin Address in PHP?

You need to understand that Bitcoin address and ...READ MORE

answered Aug 28, 2018 in Blockchain by Perry
• 17,100 points
5,481 views
0 votes
1 answer

bitcoin to currency converter and it's reverse in php

Ok, you can get the value by ...READ MORE

answered Mar 31, 2022 in Blockchain by Rahul
• 9,680 points
797 views
0 votes
1 answer

bitcoin to currency converter and it's reverse in php

Ok, you can get the value by ...READ MORE

answered Apr 7, 2022 in Blockchain by Aditya
• 7,680 points
1,749 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 26,740 points
45,297 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,946 views
0 votes
1 answer

How do I add multiple recipients for transactions via Blockchain API?

Convert the recipes into JSON objects. x = ...READ MORE

answered Jul 6, 2018 in Blockchain by Perry
• 17,100 points
927 views
0 votes
1 answer

Send Payment error in Blockchain API

The following code should help: $address = null; try ...READ MORE

answered Jul 6, 2018 in Blockchain by Perry
• 17,100 points
1,784 views
0 votes
1 answer

Problem installing bitcoin wallet in Ubuntu.

You install Bitcoind using the following commands: sudo ...READ MORE

answered Aug 22, 2018 in Blockchain by slayer
• 29,370 points
1,028 views
+2 votes
5 answers

How do I parse this JSON array in PHP?

/** * Firstly collect the ...READ MORE

answered Sep 3, 2018 in Blockchain by slayer
• 29,370 points
6,363 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP