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.


 Subscribe in a reader

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

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old May 9th, 2006, 09:21
Reputable Member
Join Date: Feb 2006
Location: London
Age: 26
Posts: 103
Thanks: 0
Thanked 1 Time in 1 Post
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old May 9th, 2006, 10:57
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,186
Blog Entries: 7
Thanks: 27
Thanked 23 Times in 20 Posts
Re: better way to write this?

Beat me to it iZone...
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old May 9th, 2006, 11:20
craig's Avatar
Reputable Member
Join Date: Sep 2005
Location: Preston, UK
Age: 21
Posts: 382
Thanks: 0
Thanked 0 Times in 0 Posts
Re: better way to write this?

Obviously gettin too slow in your old age!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old May 9th, 2006, 11:21
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,186
Blog Entries: 7
Thanks: 27
Thanked 23 Times in 20 Posts
Re: better way to write this?

bah.
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
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 07:18.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization 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