You have it backwards. Javascript is able to “detect” and make a change as its client side. PHP is server side, so it has the privilege of already knowing where the div is going to be.
I suppose you could parse the markup and use PHP to add the content then serve the page.
But IMHO if you really want to do this server-side I’d look into using template PHP files that have something like
get_content(‘342’);
in them.
Or similar to Kyle’s example
$div_content = get_content(‘745’);
…
<?php echo $div_content; ?>