Given a string:
$pages = "1,2,3,4,5,6";
Create a function that gets the numbers on the left and the right of the given element. I expect this ouputs:
pagination(1); // array('prev' => null, 'next' => 2);
pagination(2); // array('prev' => 1, 'next' => 3);
pagination(6); // array('prev' => 5, 'next' => null);
I don't want to use explode() i want to use only only use string manipulation functions. This it's was i tried but is 8 apear ... i need to see, the 5 between ','
<?php
$number = "5";
$pages = "1,2,3,4,5,6";
$x = strpos($pages, $number);
echo $x;
?>
Haven't tested it, but I think this could give you an idea.
This doesnt work for numbers >= 10.
Since this looks like homework, I suggest you take something you see here and modify it.