String manipulation

Asked

Viewed 45 times

0

I have a string thus:

$string = "<div class="legenda">Legenda</div>
    <li><a href="link2">02</a></li>
    <li><a href="link3">03</a></li>
    <li><a href="link4">04</a></li>
    <div class="dublado">Dublado</div>
    <li><a href="link1">01</a></li>
    <li><a href="link2">02</a></li>
    <li><a href="link3">03</a></li>
";

I wanted a help to manipulate and she’d be shown that way

Legenda
1
1
1
Dublado
1
1
1

In case, show only what is inside the <div class="legenda"> of <a> and the other div.

Someone has a solution?

1 answer

0

See if this helps:

CSS:

.legenda, li, .dublado {
  display: inline-block;
}

a {
  text-decoration: none;
}

PHP

<?php

$string = '<div class="legenda">Legenda</div>
<li><a href="link2">02</a></li>
<li><a href="link3">03</a></li>
<li><a href="link4">04</a></li>
<div class="dublado">Dublado</div>
<li><a href="link1">01</a></li>
<li><a href="link2">02</a></li>
<li><a href="link3">03</a></li>
';
  • It didn’t work :/ so it would hide the div, wanted to manipulate the string to modify them

Browser other questions tagged

You are not signed in. Login or sign up in order to post.