Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to extract part of the path and the ending file name with Regex?
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/173868/how-to-extract-a-file-extension-in-php">How to extract a file extension in PHP?</a> </p> </blockquote> <p>I need to build an associative array with the plugin name and the language file it uses in the following sequence:</p> <pre><code>/whatever/path/length/public_html/wp-content/plugins/adminimize/languages/adminimize-en_US.mo /whatever/path/length/public_html/wp-content/plugins/audio-tube/lang/atp-en_US.mo /whatever/path/length/public_html/wp-content/languages/en_US.mo /whatever/path/length/public_html/wp-content/themes/twentyeleven/languages/en_US.mo </code></pre> <p>Those are the language files WordPress is loading.<br> They are all inside <code>/wp-content/</code>, but with variable server paths.<br> I'm looking only for those inside the plugins folder, grab the plugin folder name and the filename.</p> <p>Hipothetical case in PHP, where <strong><code>reg_extract_*</code></strong> functions are the parts I'm missing:</p> <pre class="lang-php prettyprint-override"><code>$plugins = array(); foreach( $big_array as $item ) { $folder = reg_extract_folder( $item ); if( 'plugin' == $folder ) { // "folder-name-after-plugins-folder" $plugin_name = reg_extract_pname( $item ); // "ending-mo-file.mo" $file_name = reg_extract_fname( $item ); $plugins[] = array( 'name' =&gt; $plugin_name, 'file' =&gt; $file_name ); } } </code></pre> <p>[update]</p> <p>Ok, so I was missing quite a basic function, <code>pathinfo</code>... :/</p> <p>No problem to detect if <code>/plugins/</code> is contained in the array.</p> <p>But what about the plugin folder name?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload