Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 20 Jul 2002, 01:26
JJR512's Avatar
JJR512 JJR512 is offline
 
Join Date: Oct 2001
Real name: Justin J. Rebbert
Question How do I explode, do something, implode?

Let's say I have an array:

$array = "50,60,70,80,90";

And I want to take each element of the array and do something with it. The specific something is a mathmatical operation; let's say I want to subtract 10 from each number. Then, after subracting 10 from each number, I want so put all the results back into a new array. The new array would look like "40,50,60,70,80".

How do I write this?

I know to start with something like:

$exploded_array = explode(",",$array)

But where do I go from there? (And in the explode(), does $array need to be enclosed in quotes or not?)
__________________
-Justin J. "JJR512" Rebbert
www.JJR512.com: Chat about anything!
Reply With Quote
  #2  
Old 20 Jul 2002, 08:16
Chen's Avatar
Chen Chen is offline
 
Join Date: Sep 2001

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

You can also use foreach, like this:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

But I think the first method is more elegant.
__________________
Chen Avinadav
Formerly vBulletin.org Owner and Founder

chen@avinadav.com
Reply With Quote
  #3  
Old 20 Jul 2002, 08:24
Neo's Avatar
Neo Neo is offline
 
Join Date: Oct 2001
Real name: Dan
Chen I forget but why do you add a & to the front of a variable in certain cases?
Reply With Quote
  #4  
Old 20 Jul 2002, 08:28
JJR512's Avatar
JJR512 JJR512 is offline
 
Join Date: Oct 2001
Real name: Justin J. Rebbert
Thanks!
__________________
-Justin J. "JJR512" Rebbert
www.JJR512.com: Chat about anything!
Reply With Quote
  #5  
Old 20 Jul 2002, 08:54
Chen's Avatar
Chen Chen is offline
 
Join Date: Sep 2001
Originally posted by Neo
Chen I forget but why do you add a & to the front of a variable in certain cases?
I can't explain the whole thing in a post, read this:
http://php.fastmirror.com/manual/en/...references.php
__________________
Chen Avinadav
Formerly vBulletin.org Owner and Founder

chen@avinadav.com
Reply With Quote
  #6  
Old 20 Jul 2002, 10:25
Neo's Avatar
Neo Neo is offline
 
Join Date: Oct 2001
Real name: Dan
Thanks for the help as always.
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
Forum Jump


New To Site? Need Help?

All times are GMT. The time now is 21:03.

Layout Options | Width: Wide Color: