• 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

301 Redirect to remove query string on homepage only

Reload parent page after submit in iframe

Call to a member function fetch_field() on a non-object MySQLiDB

If you intend you use SMTP, add your SMTP Code after this Line

I want to display default profile image if user do not have profile image

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

Explode not working properly with dash

Backend cannot be reached after Typo3 login screen

target [LaravelFortifyContractsRegisterViewResponse] is not instantiable

Transpose and flatten two-dimensional indexed array where rows may not be of equal length

Log a user out of a website when they put their computer to sleep

How to solve Duplicate entry '0' for key 'PRIMARY' in Wordpress?

how to pass row id in href of a tag in codeigniter controller?

How can I get new CSRF token in LARAVEL by using ajax

Google API Heatmap Layer exception, why?

About Contact Privacy policy Terms and conditions