• 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

Why isn't my PHP exception working?

target [LaravelFortifyContractsRegisterViewResponse] is not instantiable

Add customer email and phone in "Order" column to admin orders list on Woocommerce

Refresh specific HTML content that retrieves data from MySQL

how to use extended ASCII instead of unicode in PHP

Add a text next to stock quantity if it is less than 10 in Woocommerce single product

Remove product downloads section in woocommerce email notifications

PHP: How to quickly split a key=value file into associative array

PHP array sort and remove duplicates by two field values

merge all files in directory to one text file

WordPress Security Standards want me to escape my html, but how to do it correctly?

WooCommerce - unset "<product> removed notice…" on cart page

How to get unique slug to same post-title for other time too?

PHP: How to raise number to (tiny) fractional exponent?

Hide specific products from unlogged users based in product category in WooCommerce

About Contact Privacy policy Terms and conditions