1

This is my var_dump();

string(244) "a:3:{s:3:"url";s:81:"http://rsl.local/wp-content/uploads/wp-user-manager-uploads/2018/03/time-icon.png";s:4:"path";s:101:"/Users/aaronsummers/Sites/rsl-awards/wp-content/uploads/wp-user-manager-uploads/2018/03/time-icon.png";s:4:"size";i:1342;}"

How can i grab the url section? "http://rsl.local/wp-content/uploads/wp-user-manager-uploads/2018/03/time-icon.png" (without the quotes)

2

3 Answers 3

5

This is a serialized PHP array, so a simple unserialize on that string should give you an array back on which you can just access the url key:

$array = unserialize($yourString);
echo $array['url'];
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the help, i'd not used unserialize before, unfortunately Alex pipped you to the post by a few seconds.
3

This is a serialized string. Just unserialize it, and then dereference the 'url' key:

$url = unserialize($str)['url'];

2 Comments

This is a revelation, thanks. I've not come across unserialize before.
I was watching the post, you answered 5 seconds before @ChristianM
1

Use PHP unserialize to get the url.

$url = unserialize($str);
http://php.net/manual/en/function.unserialize.php

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.