• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Extract string between first whitespace and last whitespace in php

php


PHP Snippet 1:

<?php
$str_arr = explode(" ", "Your long sentence here.");
$sub_arr = array_slice($str_arr, 1, count($str_arr)-2);
$extracted_str = implode(' ', $sub_arr);
echo $extracted_str; // long sentence

Related Snippets

Nginx disallowing execution of PHP in uploads directory with Magento

VB.NET WebRequest with PHP POST

How to connect to MSSQL Server with PHP from Ubuntu 18.04?

carbon generated datetime not stored correctly into the database

Laravel Command Schedule Not Working Properly

array_key_exists(): The first argument should be either a string or an integer

How to modify CSS in a specific page of the WP admin dashboard (backend)

Get WooCommerce product variation attribute terms in admin products general box

How to install php_imagick on wamp64

Getting values for an enum?

Create a new line whenever an array value reaches more than 10 characters

SQL AVG() to 2 decimals

wordpress function breaks wp-admin

*** ERROR *** The PHP configuration loaded file is: c:/wamp64/bin/php/php8.1.0/php.ini - should be: c:/wamp64/bin/apache/apache2.4.53.1/bin/php.ini

Redirect to previous page with php

About Contact Privacy policy Terms and conditions