Jump to content

[SOLVED] String seperation and assignment


EchoFool

Recommended Posts

Hey

 

I have a string like this:

 

$string = '12,14,37,124,5,77,35,74';

 

Now each number represents what the result was for each day. So 12 was yesterday, 14 was day before than and so on.

 

What im trying to do is make a script then to pick a day of the list and display that day... so say i wanted to display the result for 3 days ago...

 

That would be 37.

 

How would i do it in a while loop.. to cycle through it and then only echo the result when $var in the count of the while loop equalled the $day = 3... sumin like this

 

<?php
$getday = 3;
$var = 1;
While ( some thing  ) {
If($var == $getday){
Echo $result;
}
$var = $var + 1;
}
?>

 

How ever if there is a more efficient way id be interested to know your view to it.. the amount of numbers in the list could be hundreads just to add.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.