take a look at my code...
Posted: Wed Jun 17, 2009 2:41 am
I have a variable with a value like this:
$var='<span class="google-src-text" style="direction: ltr; text-align: left">
Jeśli otrzymałeś token ze strony Joobi możesz go wprowadzić klikając na
<span style="font-weight: bold;">Wprowadź Token</span></span>
Si vous avez reçu le jeton Joobi vous pouvez entrer en cliquant sur le
<span style="font-weight: bold;">jeton de clé</span>
</span>';
Now, I want to remove<span style="font-weight: bold;">Wprowadź Token</span>and I have
a code for that:
$var= preg_replace('#<span style\b[^>]*>(?:.*?)>#s','',$var);
but my problem is I dont want to remove <span style="font-weight: bold;">jeton de clé</span>
because when I do the preg_replace, it also removes the <span style="font-weight: bold;">jeton de clé</span>.
I need to remove the <span style="font-weight: bold;">Wprowadź Token</span> when it is inside a <span class>...</span> tag. Like this:
<span class="google-src-text" style="direction: ltr; text-align: left">
Jeśli otrzymałeś token ze strony Joobi możesz go wprowadzić klikając na
<span style="font-weight: bold;">Wprowadź Token</span></span>
so I should have a new value for my variable and it should be like this:
$var = '<span class="google-src-text" style="direction: ltr; text-align: left">
Jeśli otrzymałeś token ze strony Joobi możesz go wprowadzić klikając na
</span>
Si vous avez reçu le jeton Joobi vous pouvez entrer en cliquant sur le
<span style="font-weight: bold;">jeton de clé</span>
</span>';
Notice that the <span style="font-weight: bold;">Wprowadź Token</span> is removed....
How can I make it possible that I only remove the <span style>...</span> when it is inside a <span class>...</span>. If you could see it, the <span style> I removed is the <span style> that is inside the <span class>...</span>.
Please help me with this... THanks in advance! =)
$var='<span class="google-src-text" style="direction: ltr; text-align: left">
Jeśli otrzymałeś token ze strony Joobi możesz go wprowadzić klikając na
<span style="font-weight: bold;">Wprowadź Token</span></span>
Si vous avez reçu le jeton Joobi vous pouvez entrer en cliquant sur le
<span style="font-weight: bold;">jeton de clé</span>
</span>';
Now, I want to remove<span style="font-weight: bold;">Wprowadź Token</span>and I have
a code for that:
$var= preg_replace('#<span style\b[^>]*>(?:.*?)>#s','',$var);
but my problem is I dont want to remove <span style="font-weight: bold;">jeton de clé</span>
because when I do the preg_replace, it also removes the <span style="font-weight: bold;">jeton de clé</span>.
I need to remove the <span style="font-weight: bold;">Wprowadź Token</span> when it is inside a <span class>...</span> tag. Like this:
<span class="google-src-text" style="direction: ltr; text-align: left">
Jeśli otrzymałeś token ze strony Joobi możesz go wprowadzić klikając na
<span style="font-weight: bold;">Wprowadź Token</span></span>
so I should have a new value for my variable and it should be like this:
$var = '<span class="google-src-text" style="direction: ltr; text-align: left">
Jeśli otrzymałeś token ze strony Joobi możesz go wprowadzić klikając na
</span>
Si vous avez reçu le jeton Joobi vous pouvez entrer en cliquant sur le
<span style="font-weight: bold;">jeton de clé</span>
</span>';
Notice that the <span style="font-weight: bold;">Wprowadź Token</span> is removed....
How can I make it possible that I only remove the <span style>...</span> when it is inside a <span class>...</span>. If you could see it, the <span style> I removed is the <span style> that is inside the <span class>...</span>.
Please help me with this... THanks in advance! =)