![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Budapest
Posts: 503
|
Quick php question
I know there's an easy way of doing this, but I'm having a brain freeze.
I want to extract the domain name from this array value a:1:{s:10:"formfield1";s:17:"www.domain.com";} Anybody know how?
__________________
yeah, yeah |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Join Date: Oct 2005
Posts: 165
|
In my opinion this isn't even correct JSON.
Php has some JSON-functions, these will be the easiest way. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Damn Right I Kiss Ass!
Industry Role:
Join Date: Dec 2003
Location: Cowtown, USA
Posts: 32,391
|
This is fucked with by wordpress I am assuming. It has it's own API to pull it back out.
But if it all is in the same format.. just explode it and move on |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Registered User
Join Date: Aug 2002
Posts: 37
|
Code:
$sString = 'a:1:{s:10:"formfield1";s:17:"www.domain.com";}'; $sTemp = explode(":", $sString); $iLastIndex = count($sTemp)-1; $sDomain = str_replace( array('"', ';', '}'), "", $sTemp[$iLastIndex]); echo $sDomain; |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 | |
Confirmed User
Industry Role:
Join Date: Sep 2006
Location: Netherlands
Posts: 217
|
Quote:
So I guess you could just unserialize() it and then extract $foo['formfield'], which should yield 'www.domain.com'... [edit] After actually checking if it would work, I noticed your original isn't formatted properly... the second part claims it's going to contain a string of 17 characters when it's only a 14 character one... so this exact example won't work, but the original of 'www.domain.com' would probably work just fine :P
__________________
Dido ADAMO Advertising - Your ULTIMATE traffic partner! If you need traffic or have traffic, we'd love to help you make the best out of it! ICQ:24209500 - Skype:diederikvanschaik |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Budapest
Posts: 503
|
I ending up using something similar to this, thanks for the pointers Guys.
__________________
yeah, yeah |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Industry Role:
Join Date: Oct 2007
Posts: 1,448
|
Above is wrong. Here:
Code:
$sString = 'a:1:{s:10:"formfield1";s:17:"www.domain.com";}'; $vars = unserialize($sString); $domain = $vars['formfield1'];
__________________
xMarkPro -- Ultimate Blog Network Management Streamline your marketing operations. Centralize management of domains, pages, Wordpress blogs, sponsors, link codes, media items, sales and traffic statistics, plus more! |
![]() |
![]() ![]() ![]() ![]() ![]() |