• 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

How to send upload image through email

Destroy session upon refresh

How do I truncate a decimal in PHP?

What will the best solution for this multiple optional filter?

Get WooCommerce product variation attribute terms in admin products general box

How Can I Do LIMIT 1, 2 In WP_Query

PHP array sort and remove duplicates by two field values

How to convert a carbon into string, to take the date only?

Facebook SDK error: Cross-site request forgery validation failed. Required param "state" missing from persistent data

How to increase the PHP upload limits [duplicate]

Target class controller does not exist - Laravel 8

Phpunit partial mock + proxy Entity

Symfony there are no commands defined in the "make" namespace

Where do I need to place a hook for phpunit?

PHP function Not Working As Expected From functions.php Include File

About Contact Privacy policy Terms and conditions