0

I have the following array under $hashes:

Array
    (
        [0] => Array
            (
                [0] => "8b4bc4be1c7b2e5175b645ec6280" target="btcad"
                [1] => "4667fb10d39cc20e33fc8f60c4f4" target="btcad"
                [2] => "a98b3a8f093d0160614d28f541fb" target="btcad"
                [3] => "3c6f41fe78b58d94669d4f52e9be" target="btcad"
                [4] => "896c86451ceb88ea26291d2b6f4b" target="btcad"
                [5] => "e64a32b1e9e6978d2da38052832e" target="btcad"
                [6] => "74fe5907ab42a2610e3a6f42104e" target="btcad"
            )

    )

Now I also have a other variable named $selected which is a number, lets say $selected = 2 then I want to export the 3th line / [2] from the array to $selectedhash. In this case $selectedhash would be a98b3a8f093d0160614d28f541fb.

What is the quickest and safest way to do this way to do this in php?

2 Answers 2

3

You should look up tutorials on basic php, just access your array with a normal index.

$selectedhash = $yourArray[0][ $selected ];
Sign up to request clarification or add additional context in comments.

Comments

0

This also removes target="btcad"

$selectedhash = explode('" ', $myArray[0][$selected]);
$selectedhash = str_replace('"', '', $selectedhash[0]);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.