<?php
$recent_projects = [
[
'project_title' => 'Project Name1',
'project_url' => 'url1'
],
[
'project_title' => 'Project Name2',
'project_url' => 'url2'
],
[
'project_title' => 'Project Name3',
'project_url' => 'url3'
],
[
'project_title' => 'Project Name4',
'project_url' => 'url4'
],
[
'project_title' => 'Project Name5',
'project_url' => 'url5'
]
];
$show_x_projects = 3; // How may projects to show
$current_page = trim($_SERVER['REQUEST_URI'], '/');
// remove the project which matches with page url
$filtered_projects = array_filter($recent_projects, function ($project) use ($current_page) {
return ($project['project_url'] != $current_page);
});
// select random 3 project from filtered projects
$random_projects = array_rand($filtered_projects, $show_x_projects);
foreach ($random_projects as $index) {
$item = $filtered_projects[$index];
echo $item['project_title']."--";
}
- Output for 7.1.28, 7.1.32, 7.2.6, 7.2.23, 7.4.0
- Notice: Undefined index: REQUEST_URI in /in/6ATsH on line 26
Project Name1--Project Name2--Project Name3--
- Output for 7.2.5, 7.2.18, 7.2.20, 7.3.12
- Notice: Undefined index: REQUEST_URI in /in/6ATsH on line 26
Project Name1--Project Name2--Project Name5--
- Output for 7.2.0, 7.2.4, 7.2.10, 7.2.13, 7.3.0, 7.3.11
- Notice: Undefined index: REQUEST_URI in /in/6ATsH on line 26
Project Name1--Project Name2--Project Name4--
- Output for 7.1.33, 7.2.1, 7.2.3, 7.2.9, 7.3.7, 7.3.9 - 7.3.10
- Notice: Undefined index: REQUEST_URI in /in/6ATsH on line 26
Project Name2--Project Name3--Project Name4--
- Output for 7.1.31, 7.2.8, 7.2.11, 7.2.25, 7.3.2, 7.3.5, 7.3.8
- Notice: Undefined index: REQUEST_URI in /in/6ATsH on line 26
Project Name1--Project Name3--Project Name4--
- Output for 7.1.26, 7.2.12, 7.3.6
- Notice: Undefined index: REQUEST_URI in /in/6ATsH on line 26
Project Name2--Project Name4--Project Name5--
- Output for 7.2.14, 7.2.21, 7.3.4
- Notice: Undefined index: REQUEST_URI in /in/6ATsH on line 26
Project Name1--Project Name4--Project Name5--
- Output for 7.2.7, 7.2.15 - 7.2.16, 7.2.22, 7.3.3
- Notice: Undefined index: REQUEST_URI in /in/6ATsH on line 26
Project Name1--Project Name3--Project Name5--
- Output for 7.1.29 - 7.1.30, 7.2.17, 7.3.1
- Notice: Undefined index: REQUEST_URI in /in/6ATsH on line 26
Project Name3--Project Name4--Project Name5--
- Output for 7.1.25, 7.1.27, 7.2.2, 7.2.19, 7.2.24
- Notice: Undefined index: REQUEST_URI in /in/6ATsH on line 26
Project Name2--Project Name3--Project Name5--
preferences:
35.77 ms | 418 KiB | 5 Q