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
https://forums.phpfreaks.com/topic/162911-solved-string-seperation-and-assignment/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.