Developer's Manual  Function Reference  Functions to work with content tables  suParsePath

suParsePath

Splits a path to the page into respective number of paths to integral pages.


mixed suParsePath
(string path [, int skip_from_start [, int skip_from_end [, int output_type]]])

The function takes a path to the page and breaks it into paths to every integral-page within the path. Parameters skip_from_start and skip_from_end tell how many levels to skip from the beginning and from the end of the given path. Parameter output_type is a bitmask that specifies the sorting order of the result and the way how the result will be presented.

Examples

<?
$path
= suPathById(75);
print_r(suParsePath($path));

// This will print  
// "/","/dev/","/dev/reference/","/dev/reference/content/","/dev/reference/content/supathbyid/"
?>

The below example shows how the parameters skip_from_start and skip_from_end affect the output.

<?
$path
= suPathById(75, 2, 1);
print_r(suParsePath($path));

// This will print  
// "/dev/reference/","/dev/reference/content/"
?>

The bitmask output_type defines the way how the result will be presented. The zero bit switches output between string and array. The first bit defines the sort order.

<?
$path
= suPathById(75, 0, 0, 1);
print_r(suParsePath($path));

/* The result is array
Array
(
    [0] => /
    [1] => /dev/
    [2] => /dev/reference/
    [3] => /dev/reference/content/
    [4] => /dev/reference/content/supathbyid/
)
*/

$path = suPathById(75, 0, 0, 2);
print_r(suParsePath($path));

// The result is string
// "/dev/reference/content/supathbyid/","/dev/reference/content/","/dev/reference/","/dev/","/"

$path = suPathById(75, 0, 0, 3);
print_r(suParsePath($path));

/* The result is array sorted in reverese order
Array
(
    [0] => /dev/reference/content/supathbyid/
    [1] => /dev/reference/content/
    [2] => /dev/reference/
    [3] => /dev/
    [4] => /
)
*/
?>
Please login to add comments.