vBulletin Modifications

looking for php way to declare array fields as vars

Welcome to vBHackers.com! - vBHackers Updates:

Go Back   vBulletin Modifications > General vBulletin Section > General vBulletin Support

Reply
 
LinkBack Thread Tools
Old 08-23-2006, 10:21 AM   #1
Coder
Idan's Avatar
Join Date: Feb 2005
Real Name: Idan
Location: Israel
Idan is on a distinguished road

Default looking for php way to declare array fields as vars

i know it sounds weird, just something i've been trying to do, will explain some more:
if for example i have array named $my_array, with for example:
$my_array['field1'] = "1";
$my_array['field2'] = "2";
& so on

i'm looking for smart way of making this as if i wrote:
$field1 = "1";
$field2 = "2";

so assuming i have this array that is populated via FOR loop, i can later on pass this array as seperate vars.

i'm aiming to do something like WetWired did in his activity hack code (http://www.vbulletin.org/forum/showthread.php?t=93831), where in there he used an array named $output in the postbit_start hook, and somehow got it to be declared as seprate digits vars on the template itself.

i've tried to use php eval() function, but that didn't go so well.

if anyone got some idea on & can give few pointers will be appreciated.
thx.
__________________
Idan / vBHackers.com
vBSEO 3.1 GOLD Released vB Blogs Compatible | Non-Encrypted | Branding Removal Option | Sitemaps 2.1 | Language Packs

Crawlability Network: vBulletin SEO | vBulletin Hackers




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Old 08-23-2006, 10:45 AM   #2
vBulletin Guru
Nick R's Avatar
Join Date: May 2006
Real Name: Nick
Location: Cyberspace, UK
Nick R is on a distinguished road

Default

Well the manual way would be: $field1 = $my_array['field1'];
But of course that isn't to sensible if you have 200 vars. xD

Underneath your code put:
You must first be a registered member to view any code.
so then your code should look like:
You must first be a registered member to view any code.
You can then use $field1 and $field2.

Last edited by Nick R; 08-23-2006 at 11:44 AM..




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-23-2006, 11:04 AM   #3
Coder
Idan's Avatar
Join Date: Feb 2005
Real Name: Idan
Location: Israel
Idan is on a distinguished road

Default

thx, will try that.

EDIT: still haven't checked it (needs to switch to my linux, will do it in about an hour), just wanted to add i was aware foreach loop can do this sort of work, but wanted to know if there was any internal vbulletin function for it to make life easier. like mentioned, in the first post - as in that activity hack he made, he didn't made any foreach loop & that still worked, so it puzzled me a bit.

Last edited by Idan; 08-23-2006 at 12:27 PM..




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-23-2006, 12:58 PM   #4
vBulletin Guru
Nick R's Avatar
Join Date: May 2006
Real Name: Nick
Location: Cyberspace, UK
Nick R is on a distinguished road

Default

Apparently the globalize() function was dropped in 3.5. Which was the alternative.




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-01-2006, 12:58 PM   #5
vBulletin Guru
Nick R's Avatar
Join Date: May 2006
Real Name: Nick
Location: Cyberspace, UK
Nick R is on a distinguished road

Default

*bumps up old thread*

You can also use:
You must first be a registered member to view any code.




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-01-2006, 02:17 PM   #6
Coder
Idan's Avatar
Join Date: Feb 2005
Real Name: Idan
Location: Israel
Idan is on a distinguished road

Default

thanks for the tip - this is what i was looking for ;)




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-01-2006, 03:32 PM   #7
vBulletin Guru
Nick R's Avatar
Join Date: May 2006
Real Name: Nick
Location: Cyberspace, UK
Nick R is on a distinguished road

Default

ok, no problem

You can also do: extract($my_array, EXTR_PREFIX_SAME, "pre"); Which would add the prefix pre to it if the variable already existed.

(http://uk2.php.net/manual/en/function.extract.php)




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Extra Threadfields Lite(Add Text, Radio, Drop Down, & Checkbox Fields To Threads!) gio~logist vBulletin 3.5 / 3.6 Hack Releases 6 05-29-2007 10:35 PM


All times are GMT -3. The time now is 05:16 PM.

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc. (Patent Pending)