回答編集履歴

1

はいはい

2018/11/15 08:56

投稿

papinianus
papinianus

スコア12705

test CHANGED
@@ -1 +1,17 @@
1
1
  [array_seach](http://php.net/manual/ja/function.array-search.php)でキー(何番目か)が分かるので、+1,-1すればいいのでは?
2
+
3
+
4
+
5
+ ```php
6
+
7
+ $pos = array_search($this_id, $post_id_index, true);
8
+
9
+ $prev_pos = $pos - 1;
10
+
11
+ $next_pos = $pos + 1;
12
+
13
+ if($prev_pos < 0) $prev_pos = null;
14
+
15
+ if($next_pos >= count($post_id_index)) $next_pos = null;
16
+
17
+ ```