If you pre-multiply both sides by $P$ you end up with a Sylvester equation - see the Wikipedia entry here:-
$$PA+AP=PB$$
Suppose $P$ is an $n\times n$ diagonal matrix:-
$$P=\left(\begin{array}{cccc} p_1 & 0 & \cdots & 0\\ 0 & p_2 & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \cdots & p_n \end{array}\right)$$
and matrices $A$ and $B$ are given by
$$A=\left(\begin{array}{cccc} a_{11} & a_{12} & \cdots & a_{1n}\\ a_{21} & a_{22} & \cdots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n1} & a_{n2} & \cdots & a_{nn} \end{array}\right)$$
$$B=\left(\begin{array}{cccc} b_{11} & b_{12} & \cdots & b_{1n}\\ b_{21} & b_{22} & \cdots & b_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ b_{n1} & b_{n2} & \cdots & b_{nn} \end{array}\right)$$
Then (using the Kronecker product formulation, and after some manipulation) we end up with a relationship between column $k\in\{1,2,\cdots,n\}$ of $A$ (denote as $A_{k}=[a_{1k},a_{2k},\cdots,a_{nk}]^T$) and column $k$ of $PB$ (denote as $[PB]_{k}=[p_1b_{1k},p_2b_{2k},\cdots,p_nb_{nk}]^T$) as follows:-
$$(P+p_kI)A_{k}=[PB]_{k}\Rightarrow A_{k}=(P+p_kI)^{-1}[PB]_k$$
where $I$ is the $n\times n$ identity matrix, so that $P+p_kI$ is a diagonal matrix.