0

how extract string from array value?

array:1 [▼
  0 => "dmapi-auth=d0e38a35d83fea420d0bb1e93e2f4b964d0a205b; path=/"
]

so value is "dmapi-auth=d0e38a35d83fea420d0bb1e93e2f4b964d0a205b;"

I need to get string after dmapi-auth= and before ; -char. like d0e38a35d83fea420d0bb1e93e2f4b964d0a205b

Thanks Mika.

1 Answer 1

1

You can do like:

$arr = [
    0 => "dmapi-auth=d0e38a35d83fea420d0bb1e93e2f4b964d0a205b; path=/"
];
$arr = explode(';', $arr[0]);

$arr = substr($arr[0], strpos($arr[0], "=") + 1);
Sign up to request clarification or add additional context in comments.

1 Comment

thank you, I have even extended little bit: $authSid = $res->getHeader('Set-Cookie'); $arr = explode(';', $authSid[0]); $arr = substr($arr[0], strpos($arr[0], "=") + 1); dump ($arr); works as I need.

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.