zprog
04-09-2004, 12:10 AM
I am a bit new here, but I've been referred to this forum in hopes that you guys will help me. Please don't disregard this topic because it's so long, I really need your help.
I am currently trying to make a forum that looks sort of (or exactly like) that found on ticalc.org (http://www.ticalc.org), but I have met a problem. I am using a system where an ID of 1 would refer to the first reply to the main news item. An ID of 2 would refer to the second reply to the news item. However, an ID of 1.1 woud refer to the first reply to the first reply to the news item, while 1.2 would refer to the second reply to the first reply to the news item. This goes on (theoretically infinitely), meaning that you could have something like 1.2.1.1.2.5.19.30 (these aren't decimals, they are merely integers separated by a period)
I know this is confusing, but it's difficult to put into words. You should look at ticalc.org. Basically what I have done is made an array, for example $idsarray of x elements, where x is the number of total replies (ID of 1 counts as one element, ID of 1.4.29 counts as one element), and I want to display them in order. Because someone will reply to a previous reply even after the next reply of a higher priority has been created, I need to order the array based on the following example. I was wondering if anyone could help me with the script (or if anyone knows of a forum that is in the form of ticalc.org (http://www.ticalc.org)'s).
Example:
I have the following elements to order:
1
1.1.1.1
1.1
2
1.2
1.2.1
1.1.3
1.1.1
1.1.2
I need them ordered as:
1
1.1
1.1.1
1.1.1.1
1.1.2
1.1.3
1.2
1.2.1
2
To start off, I have created a script that will find how many periods are in an element (or rather string, which is the type of element in the arrays):
CODE:
function num_times_str_appears($needle, $haystack)
{
$number = 0;
while (strstr($haystack, $needle))
{
// need to get rid of the "."
// in the beginning of the new $haystack
$temp = strstr($haystack, $needle);
$haystack = ltrim($temp, $needle);
$number++;
}
return $number;
}
I am currently trying to make a forum that looks sort of (or exactly like) that found on ticalc.org (http://www.ticalc.org), but I have met a problem. I am using a system where an ID of 1 would refer to the first reply to the main news item. An ID of 2 would refer to the second reply to the news item. However, an ID of 1.1 woud refer to the first reply to the first reply to the news item, while 1.2 would refer to the second reply to the first reply to the news item. This goes on (theoretically infinitely), meaning that you could have something like 1.2.1.1.2.5.19.30 (these aren't decimals, they are merely integers separated by a period)
I know this is confusing, but it's difficult to put into words. You should look at ticalc.org. Basically what I have done is made an array, for example $idsarray of x elements, where x is the number of total replies (ID of 1 counts as one element, ID of 1.4.29 counts as one element), and I want to display them in order. Because someone will reply to a previous reply even after the next reply of a higher priority has been created, I need to order the array based on the following example. I was wondering if anyone could help me with the script (or if anyone knows of a forum that is in the form of ticalc.org (http://www.ticalc.org)'s).
Example:
I have the following elements to order:
1
1.1.1.1
1.1
2
1.2
1.2.1
1.1.3
1.1.1
1.1.2
I need them ordered as:
1
1.1
1.1.1
1.1.1.1
1.1.2
1.1.3
1.2
1.2.1
2
To start off, I have created a script that will find how many periods are in an element (or rather string, which is the type of element in the arrays):
CODE:
function num_times_str_appears($needle, $haystack)
{
$number = 0;
while (strstr($haystack, $needle))
{
// need to get rid of the "."
// in the beginning of the new $haystack
$temp = strstr($haystack, $needle);
$haystack = ltrim($temp, $needle);
$number++;
}
return $number;
}