Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

129
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda