0

I want to capture just one part of what Getrawtransaction returns, but it returns an array within an array that i can't seem to process.

I.e when

$txid = '4f52e7769fe23059a4f0fa2b66ca0ba9595812654b90cc0526ddb9703a3e1b33';

$txidarray = ($rpc->getrawtransaction($txid,1));

then I can grab the whole "vout" array element(s) with :

print_r($txidarray[vout])

;

i.e that returns :

> Array (
>     [0] => Array
>         (
>             [value] => 0.077
>             [n] => 0
>             [scriptPubKey] => Array
>                 (
>                     [asm] => OP_DUP OP_HASH160 efe11230ccff2380c3115e2826098931bb76ccef OP_EQUALVERIFY OP_CHECKSIG
>                     [hex] => 76a914efe11230ccff2380c3115e2826098931bb76ccef88ac
>                     [reqSigs] => 1
>                     [type] => pubkeyhash
>                     [addresses] => Array
>                         (
>                             [0] => 1NsN84QPXSXEdojiC482PnJUGNfx9XduQ6
>                         )
> 
>                 )
> 
>         )
> 
>     [1] => Array
>         (
>             [value] => 0.02636684
>             [n] => 1
>             [scriptPubKey] => Array
>                 (
>                     [asm] => OP_DUP OP_HASH160 ae57d86c288389e086eadf1bc50998d86ad2828a OP_EQUALVERIFY OP_CHECKSIG
>                     [hex] => 76a914ae57d86c288389e086eadf1bc50998d86ad2828a88ac
>                     [reqSigs] => 1
>                     [type] => pubkeyhash
>                     [addresses] => Array
>                         (
>                             [0] => 1Gtqoz4tNTLYBR13AxypwsXupsevcy5QPq
>                         )
> 
>                 )

But how can i grab ONLY "1Gtqoz4tNTLYBR13AxypwsXupsevcy5QPq" ???

I just want to get that address from the getrawtransaction for an txid !!

I tried :

print_r($txidarray[vout,0,scriptkey[0]);

but does not work, no clue as to what the correct syntax is !! anyone can help me ? many thanks !

1

Looks like you're indexing the array incorrectly.

Try:

print_r($txidarray[vout][1][scriptPubKey][addresses][0]);
0

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.