Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

128
Visualizações
How to export class's of css and put into array with php?

hello guyes I have CSS code and I'm trying to find a way to get only the CSS Class's name Only and clear coma and open&close tag and value and put it into an array in PHP

Example:

.dungarees {
  content: "\ef04";
}
.jacket {
  content: "\ef05";
}
.jumpsuit {
  content: "\ef06";
}
.shirt {
  content: "\ef07";
}

and I want to do a a function with PHP to convert it into an array like this

$my_array('dungarees','jacket','jumpsuit','shirt');

is there any function with php or even jquery to deal with this? thanks

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can create such an array with a simple Regex.

$cssText = <<<'_CSS'
.dungarees {
  content: "\ef04";
}
.jacket {
  content: "\ef05";
}
.jumpsuit {
  content: "\ef06";
}
.shirt {
  content: "\ef07";
}
_CSS;

$matches = [];
preg_match_all('/\.([\w\-]+)/', $cssText, $matches);
$myArray = $matches[1];

print_r($myArray);

And will result in

Array
(
    [0] => dungarees
    [1] => jacket
    [2] => jumpsuit
    [3] => shirt
)
about 4 years ago · Juan Pablo Isaza Relatório

0

Scan the string line by line, expecting it to begin with . and end with {

<?php
$result = [];
$content_of_css = '
.dungarees {
    content: "\ef04";
  }
  .jacket {
    content: "\ef05";
  }
  .jumpsuit {
    content: "\ef06";
  }
  .shirt {
    content: "\ef07";
  }

';

// or $content_of_css = file_get_contents("path_to_css");

$arr = explode("\n", $content_of_css);
foreach ($arr as $line) {
    $line = trim($line);
    if (strrpos($line, ".") === 0) {
        $result[] = trim(substr($line, 1, strlen($line) - 2));
    }
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda