Answer the question
In order to leave comments, you need to log in
The script is behaving very strangely. What to do if everything is taken into account in the condition, but it turns out not at all?
Hello friend. If you wandered here, then here is the code:
case "catalog":
$number_of_page = (int)$callback_data[1];
$catalog = $parser->catalog();
$catalog_count = count($catalog);
$catalog = array_slice($catalog,$number_of_page,1);
$img = $catalog[0]["img"];
$title = $catalog[0]["title"];
$link = str_replace(["http://","https://"],"",$catalog[0]["link"]);
$next_text = "\xE2\x96\xB6";
$prev_text = "\xE2\x97\x80";
$next = $number_of_page+1;
$prev = $number_of_page-1;
$buttons_keys = [
["text" => $prev_text, "callback_data" =>"catalog_".$prev],
["text" => "Подробнее", "url" =>"$link"],
["text" => $next_text, "callback_data" =>"catalog_".$next],
];
$i = (int)0;
if($number_of_page <= $i){
unset($buttons_keys[0]);
sort($buttons_keys);
}elseif($number_of_page >= ($catalog_count-1)){
unset($buttons_keys[2]);
sort($buttons_keys);
}
if($number_of_page != $i){
$telegram->deleteMessage([
"chat_id" => $callback_chat_id,
"message_id" => $callback_message_id,
]);
}
$buttons = [
$buttons_keys,
];
$keyboard = json_encode(["inline_keyboard"=>$buttons]);
$telegram->sendPhoto([
"chat_id" => $callback_chat_id,
"photo" => $img,
"parse_mode" => "Markdown",
"reply_markup" => $keyboard,
"caption" => "*$title*",
]);
break;
Answer the question
In order to leave comments, you need to log in
if($number_of_page <= $i){ ... }
if($number_of_page != $i){ ... }
Before if($number_of_page != $i){
var_dump, dump both variables and look at the result.
Topic closed. I'm blind and inattentive you know who. - forgot to add one exception
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question