• 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

renameColumn migration fails for existing column with columns does not exist error

PHP array_filter with arguments

PHP: Print caught exception like Xdebug

GA4 custom event from server side, can someone tell me how i can do the following code in php?

Could not decode a text frame as UTF-8.

Symfony - "framework.test" config is not set to true

Magento 2 - Controller returning blank page

Attempt to read property "view" on null when sending password reset email

Add rows to Single product Additional information table in WooCommerce 3.6

Install mysql client in docker image

How can I access an array/object?

Laravel Multi-language routes without prefix

Google API Heatmap Layer exception, why?

If action is on a different page do I use fwrite function

Laravel Blade checkbox not checked

About Contact Privacy policy Terms and conditions