I am working on my PHP to check to output the number in the variable that if the string is contains then do something.
When I try this:
$attached_file = 'attid: ' . $attid . ' filename: ';
if(strpos($files, $attached_file') !== false) {
echo "here.......................now";
}
It wont let me get pass so when I try this:
$attached_file = 'attid: 0 filename: ';
if(strpos($files, $attached_file') !== false) {
echo "here.......................now";
}
It works fine. I can get pass on the if statement with no problem.
Here is the array for the $attached_arr:
Array ( [0] => attid: 0.1 filename: what-is-bootstrap.png [1] => attid: 0 filename: how-ajax-work.png [2] => )
Here is the full code:
<?php
//Connect to the database
include('config.php');
$id = '3';
$mailbox = $link->prepare("SELECT * FROM inbox WHERE id = ?");
$mailbox->execute([$id]);
$attached_arr = array();
// set the resulting array to associative
$row = $mailbox->fetch(PDO::FETCH_ASSOC);
if($mailbox->rowCount() == 1)
{
$mailbox_attached_files = $row['attached_files'];
$attached_arr = explode("\n", $mailbox_attached_files);
$attid = 0;
foreach ($attached_arr as $files) {
$attached_file = 'attid: ' . $attid . ' filename: ';
$attached = '';
if(strpos($files, $attached_file) !== false) {
echo "here.......................now";
//$attached = trim(strrchr($files, ':'), ': ');
}
$attid++;
}
}
$mailbox = null;
?>
Can you please show me an example how I could pass on the if statement when I output the number in the variable attached_file??
Thank you.