Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
¿Cómo exportar clases de css y ponerlas en una matriz con php?

hola chicos, tengo un código CSS y estoy tratando de encontrar una manera de obtener solo el nombre de la clase CSS Solo y borrar el coma y abrir y cerrar la etiqueta y el valor y ponerlo en una matriz en PHP

Ejemplo:

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

y quiero hacer una función con PHP para convertirla en una matriz como esta

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

¿Hay alguna función con php o incluso con jquery para lidiar con esto? Gracias

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Puede crear una matriz de este tipo con un Regex simple.

 $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);

y resultará en

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

0

Escanee la cadena línea por línea, esperando que comience con . y terminar con {

 <?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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!