0

I am trying to get the value of Split Parts.

My code is:

<?php 
$password = "03,10,05,07,17,23";

$string = "::3:8:1::5::2:9::::6:::4::::::0:";

$string = explode(':', $string);

How to do print $string by order of $password

$string[03],$string[10],$string[05],$string[07],$string[17],$string[23]

Result Need : 391540

9
  • what is your expected result? Commented Jun 5, 2017 at 6:15
  • 1
    update your question with your desired output please Commented Jun 5, 2017 at 6:15
  • Result : 391540 @Val Commented Jun 5, 2017 at 6:26
  • wow may i know what is the logic behind this ?, really your question doesnt have sufficient info to give your answer, please update your question with proper info Commented Jun 5, 2017 at 6:27
  • 1
    maybe you posted on wrong site? puzzling.stackexchange.com Commented Jun 5, 2017 at 6:30

1 Answer 1

1

Here you goes Live demo

$password = "03,10,05,07,17,23";

$string = "::3:8:1::5::2:9::::6:::4::::::0:";

$pass = explode(',', $password);
$code = explode(':', $string);

$result = '';
foreach ($pass as $pos) {
    $pos = ((int)$pos)-1;
    $result .= $code[$pos];
}

echo $result;
Sign up to request clarification or add additional context in comments.

1 Comment

Thank You, thats what i'm locking for @Val

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.