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.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 06-30-2011, 02:58 AM   #1
thunder99
Confirmed User
 
thunder99's Avatar
 
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
thunder99 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-30-2011, 03:39 AM   #2
V_RocKs
Damn Right I Kiss Ass!
 
Industry Role:
Join Date: Dec 2003
Location: Cowtown, USA
Posts: 32,391
Without or without www.?

Without loading it as JSON shit or whatever that format is...

explode is your friend.
V_RocKs is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-30-2011, 03:52 AM   #3
misterhhs
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.
misterhhs is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-30-2011, 04:02 AM   #4
V_RocKs
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
V_RocKs is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-30-2011, 04:27 AM   #5
Soteko
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;
Soteko is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-30-2011, 06:22 AM   #6
Dido
Confirmed User
 
Dido's Avatar
 
Industry Role:
Join Date: Sep 2006
Location: Netherlands
Posts: 217
Quote:
Originally Posted by thunder99 View Post
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?
This is the way a serialized() array looks like in PHP.
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

Last edited by Dido; 06-30-2011 at 06:27 AM..
Dido is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-30-2011, 07:07 AM   #7
thunder99
Confirmed User
 
thunder99's Avatar
 
Industry Role:
Join Date: Nov 2003
Location: Budapest
Posts: 503
Quote:
Originally Posted by Soteko View Post
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;
I ending up using something similar to this, thanks for the pointers Guys.
__________________
yeah, yeah
thunder99 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-30-2011, 07:18 AM   #8
Kiopa_Matt
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'];
EDIT: Sorry, dido got it. Guess I should read the whole thread before replying.
__________________
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!

Last edited by Kiopa_Matt; 06-30-2011 at 07:20 AM..
Kiopa_Matt is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.