<p>Looks like you're indexing the array incorrectly.</p>

<p>Try:</p>

<pre><code>print_r($txidarray[vout][1][scriptPubKey][addresses][0]);
</code></pre>

CC BY-SA 3.0
2015-08-03T05:47:39.450Z
2015-08-03T05:47:39.450Z
Nick ODell
<p>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.</p>
<p>I.e when</p>
<blockquote>
<p>$txid =
'4f52e7769fe23059a4f0fa2b66ca0ba9595812654b90cc0526ddb9703a3e1b33';</p>
<p>$txidarray = ($rpc-&gt;getrawtransaction($txid,1));</p>
</blockquote>
<p>then I can grab the whole &quot;vout&quot; array element(s) with  :</p>
<blockquote>
<p>print_r($txidarray[vout])</p>
</blockquote>
<p>;</p>
<p>i.e that returns :</p>
<pre><code>&gt; Array (
&gt;     [0] =&gt; Array
&gt;         (
&gt;             [value] =&gt; 0.077
&gt;             [n] =&gt; 0
&gt;             [scriptPubKey] =&gt; Array
&gt;                 (
&gt;                     [asm] =&gt; OP_DUP OP_HASH160 efe11230ccff2380c3115e2826098931bb76ccef OP_EQUALVERIFY OP_CHECKSIG
&gt;                     [hex] =&gt; 76a914efe11230ccff2380c3115e2826098931bb76ccef88ac
&gt;                     [reqSigs] =&gt; 1
&gt;                     [type] =&gt; pubkeyhash
&gt;                     [addresses] =&gt; Array
&gt;                         (
&gt;                             [0] =&gt; 1NsN84QPXSXEdojiC482PnJUGNfx9XduQ6
&gt;                         )
&gt; 
&gt;                 )
&gt; 
&gt;         )
&gt; 
&gt;     [1] =&gt; Array
&gt;         (
&gt;             [value] =&gt; 0.02636684
&gt;             [n] =&gt; 1
&gt;             [scriptPubKey] =&gt; Array
&gt;                 (
&gt;                     [asm] =&gt; OP_DUP OP_HASH160 ae57d86c288389e086eadf1bc50998d86ad2828a OP_EQUALVERIFY OP_CHECKSIG
&gt;                     [hex] =&gt; 76a914ae57d86c288389e086eadf1bc50998d86ad2828a88ac
&gt;                     [reqSigs] =&gt; 1
&gt;                     [type] =&gt; pubkeyhash
&gt;                     [addresses] =&gt; Array
&gt;                         (
&gt;                             [0] =&gt; 1Gtqoz4tNTLYBR13AxypwsXupsevcy5QPq
&gt;                         )
&gt; 
&gt;                 )
</code></pre>
<p>But how can i grab ONLY  &quot;1Gtqoz4tNTLYBR13AxypwsXupsevcy5QPq&quot;  ???</p>
<p>I just want to get that address from the getrawtransaction for an txid !!</p>
<p>I tried :</p>
<blockquote>
<p>print_r($txidarray[vout,0,scriptkey[0]);</p>
</blockquote>
<p>but does not work, no clue as to what the correct syntax is !! anyone can help me ? many thanks !</p>

<client><php>
how to capture only one part of the getrawtransaction
Aussie in Perth
# how to capture only one part of the getrawtransaction

(Asked by: username_0 on 2015-08-03)

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 !

**Tags:** client, php


---

## 1 answers

### Answer by username_1 on 2015-08-03. Score: 1

Looks like you're indexing the array incorrectly.

Try:

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

```


---

