I'm working on PHP to output the email content. I want to check the width size through on the style of the html tag that if the width size which is greater than 400, I want to change it to 306px.
Example:
style="width: 406px;
If the width value is greater than 300, I want to change it to:
style="width: 306px;
Have is the html content on my php page:
<div style="width: 406px; height: 128px;"><div id="nw" style="left: -5px; top: -5px; cursor: nw-resize;"></div><div id="sw" style="left: -5px; bottom: -5px; cursor: sw-resize;"></div><div id="ne" style="right: -5px; top: -5px; cursor: ne-resize;"></div><div id="se" style="right: -5px; bottom: -5px; cursor: se-resize;"></div><div id="n" style="top: 0px; left: 0px; right: 0px; height: 1px; cursor: n-resize;"></div><div id="s" style="bottom: 0px; left: 0px; right: 0px; height: 1px; cursor: s-resize;"></div><div id="w" style="top: 0px; left: 0px; bottom: 0px; width: 1px; cursor: w-resize;"></div><div id="e" style="top: 0px; right: 0px; bottom: 0px; width: 1px; cursor: e-resize;"></div><img src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" alt="Google" style="width: 406px;height: 128px;"></div>
Here is the code:
$mailbox= $link->prepare("SELECT * FROM Drafts WHERE id = ?");
$mailbox->execute([$id]);
if ($mailbox->rowCount() > 0) {
$row = $mailbox->fetch(PDO::FETCH_ASSOC);
$draft_id = $row['email_id'];
$draft_attached_files = $row['attached_files'];
$draft_message = $row['message'];
if (!empty($draft_message)) {
$draft_message = base64_decode($draft_message);
}
echo '<body>
<div id="mobile-app-container" data-reactroot="" style="height: 100%; overflow-y: auto;">
<div id="app" data-test-id="mobile-app" tabindex="-1">
<div role="message" style="display: block; overflow-y: auto;">
<div id="eMB" style="overflow-y: auto;">
<div >';
echo $draft_message;
if (!empty($draft_attachments)) {
echo $draft_attachments;
}
echo '</div>
</div>
</div>
</div>
</div>';
echo "</html><body>";
I have got no idea how to check if the value is greater than 300, the only things I can think of would be like this:
if (strpos($draft_message, 'width:400px;') !== false) {
$draft_message = str_replace('width:400px;', 'width: 335px;', $draft_message);
}
I would have to write hundred of lines for each different value which is not the right way to do.
Can you please show me an example how I can check on the tag for the width size that if the width size is greater than 400, then I want to replace it with 306??
Thank you.
CodePudding user response:
Perhaps add this somewhere:
<style>
div {
max-width: 306px !important;
}
</style>
CodePudding user response:
u can try and use max width set to 306px for that part