• 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 can I make this nested location configuration use the correct path to call a php program?

Check if a string contain multiple specific words

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

if statement inside concatenation

how to create html table in php

Shopify password update using Shopify API

Yii2 select2 database exception number of bound variables does not match number of tokens

Inserting Country Selection into MySQL PHP [duplicate]

using random function but it's displaying duplicates

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

woocommerce_wp_select options array from product attribute terms

carbon generated datetime not stored correctly into the database

Symfony redirect if already loggedin from login page

Target class controller does not exist - Laravel 8

How to extract price from given url using Xpath?

About Contact Privacy policy Terms and conditions