You’re right – this is very much a generic PHP question. But fwiw, the issue is that you clearly want to count all JPEG files, but your sample code counts all files – so…
while ( false !== $f = $d->read() ) {
if ( in_array( strtolower( pathinfo( $f, PATHINFO_EXTENSION ) ), [ 'jpg', 'jpeg' ] ) )
$filecount++;
}
Related Posts:
- How to include checkbox in widget backend form?
- Upgrading PHP version results in “Use of undefined constant WP_CONTENT_DIR” warning?
- How to hide get_theme_mod if field empty
- renaming an admin menu item with decimal array index number
- How to get the original price of the product in woocommerce?
- How to make sure that only one wp_cron() runs at a time?
- Can’t Find a Way to Edit the Home Page Content [closed]
- Fatal error: Call to undefined function wpsc_cart_item_count()
- No wp-config.php file on local install of wordpress – site still displays
- Widgets not showing in my custom theme
- Edit category output
- Woocommerce Custom CSV export
- integrating external php library into wordpress- the right way
- To echo or not to echo?
- Different background-image by category
- Add a Different CSS Class Into The Body Tag of Different WP Pages
- How to limit the content coming from wordpress shortcodes?
- What is the fastest way to load PHP functions that are only used in one theme template?
- Writing scripts using WordPress / WooCommerce classes?
- storing wp_head in a variable?
- Change description on specific WooCommerce product status change
- How do I attach a php file to an arbitrary slug and still have access to the wp-core functions?
- Trouble creating conditional PHP for nav menu items with children for custom Walker
- Woocommerce redirect thankyou page based on product ID doesn’t empty Cart
- How to deal with checkboxes in edit page?
- search and replace preword from author
- Add meta noindex to post if it has a specific taxonomy
- Displaying Hierarchical custom taxonomy
- Open post-content in archive page in a Modal box with bootstrap
- Creating own shortcode – echoeing php variable based on JS variable
- Sort meta-value in the sequence array in pre_get_post
- How do I link a button I created in theme customizer to a function?
- Error: options page not found
- how to remove colon and white space in a string by php
- Filtering a Database Query
- Tell WP register script to load a script only when the entire page is loaded
- anyway to put inside a $outprint=sprintf()
- Can’t save php string to a custom field
- What does $_GET[‘iphone’] do?
- Appended comments but they show up above the content instead of below
- get_template_directory adding FTP root folders in urls
- What’s the best way to include PHP code in pages?
- Is there any wordpress plugin to upload images and captions to multiple pages once
- Removing the first 8-10 letters from a post?
- Line breaks inside shortcode variable
- Site Health says I’m running an older version of PHP even after I upgraded to 7.4.4
- WordPress REST API register_rest_route give a 500 error
- Where to insert redirect code based on http_referer?
- Undefined index for default custom theme option
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- woocommerce wc_create_order(); is creating multiple orders instead of one?
- Override Admin menu icon
- Trying to get property of non-object in WordPress Breadcrumbs
- Delete database record using plugin from admin panel
- Post not populating for custom post type based on category selection
- Infinite Loop – WP_Query
- call_user_func_array() expects parameter 1 to be a valid callback, function ‘———-‘ not found or invalid function name
- Including Custom fields within the_content
- How can i make a search box to search by custom field
- go to home page when i select default in select-box
- Functions.php and includes
- Error while loading wordpress site “Fatal error: Uncaught Error: Call to undefined function twentytwentyone_the_html_classes() in /home
- Database entry removed on browser refresh, Ajax PHP jQuery
- Hide specific product from Woocommerce if the logged-in user has already enrolled into the course
- How to find which .mo file is responsible for displaying a particular localized string?
- wp_Query with mutuplea values returns all posts
- How to stop hiding buttons forward / backward in pagination?
- Add to cart quantity dynamic
- Infinite looping next post link within a certain category on a post
- WordPress PHP version
- How to use a PHP file to control the content of a blog post
- Allowing Non-Latin Characters In WordPress Registration
- Woocommerce textarea format ignored
- Windows Setup: Error establishing a database connection
- Pass product object to javscript
- Making list of posts with chosen description
- How to display post_content from database in different on template page?
- Add Text Area To Child Theme’s Home Page
- Beginner Developing Theme with Bootstrap – NavMenu question
- remove blank space where sidebar was
- Using Tag Groups: Displaying groups and adjacent tags of current post
- Retrieving specific images from Media Library
- direct query to post_meta table
- Access methods in plugin template
- WordPress HTML Helper
- Adding unique marketing messages between certain products whilst using isotope/Infinite Scroll
- Notice: Undefined index: fix with isset [closed]
- Include administrator in author list
- Pass php to database in JQuery: With AJAX?
- List sibling pages widget, exclude current page
- WP Simple Fields – Single repeatable field inside repeatable field group
- Amending PHP for WordPress Theme
- get_permalink returning first letter
- Path for contact form file
- File Upload with Server in safe_mode
- WP plugin updates [duplicate]
- Custom Archive Page
- Load files content [closed]
- Shortcode for Visual Composer Grid fails turning string to integer
- AJAX WP_Query’s order and orderby parameters not working