better way to write this?

This is a discussion on "better way to write this?" within the PHP Forum section. This forum, and the thread "better way to write this? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old May 9th, 2006, 09:21
Up'n'Coming Member
Join Date: Feb 2006
Location: London
Age: 25
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Question better way to write this?

Hi,

Is there a way to write this without writing $key every time??? I tried $key == 'description' || 'includes'.... etc... but it dosen't work.

Code: Select all
} elseif (empty($value) && $key == 'description' || $key == 'includes' || $key == 'frameSize' || $key =='jumpWeight' || $key =='packedCarton' || $key == 'weight' || $key =='description2' || $key == 'thumb' || $key == 'large') {
It's being used in a class, so everything after $key == will be a variable passed from another script.

Thanks for your help!
Jim.
Reply With Quote

  #2 (permalink)  
Old May 9th, 2006, 09:37
Up'n'Coming Member
Join Date: Nov 2005
Location: England
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Re: better way to write this?

You could put the values description, includes etc in an array then use this function http://www.php.net/manual/en/function.in-array.php

Adam
Reply With Quote
  #3 (permalink)  
Old May 9th, 2006, 10:57
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Re: better way to write this?

Beat me to it iZone...
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
  #4 (permalink)  
Old May 9th, 2006, 11:20
craig's Avatar
Reputable Member
Join Date: Sep 2005
Location: Preston, UK
Age: 21
Posts: 381
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to craig
Re: better way to write this?

Obviously gettin too slow in your old age!
Reply With Quote
  #5 (permalink)  
Old May 9th, 2006, 11:21
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Re: better way to write this?

bah.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
Reply

Tags
better, write

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] do you write quicker Hosting & Domains 8 Dec 12th, 2007 05:13
Do you write like a girl? snow Webforumz Cafe 17 Jan 4th, 2007 22:14
How to write the query? accessman Databases 0 Oct 21st, 2005 16:16
Using ASP to write UpToTheMinute...... courtjester Classic ASP 4 Aug 25th, 2004 14:54


All times are GMT. The time now is 02:09.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43