I am trying to foreach multiple arrays with if condition, I have 3 arrays like below :
$contents = array('content1', 'content2', 'content3', 'content4');
$types = array('pdf', 'pdf', 'txt', 'pdf');
$links = array('link1', 'link2', 'link3');
foreach ($contents as $key => $value) {
echo "$value<br>";
if ($types[$key] == 'pdf') {
echo "$links[$key]<br>";
}
}
Output is like this :
content1
link1
content2
link2
content3
content4
Links array has 3 values, others 4 . I want if content type is pdf use link value there if not skip. And i want output like below:
content1
link1
content2
link2
content3
content4
link3
thanks for your help