• 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

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

Cross-Origin Resource Sharing (CORS) witth Laravel and Vuejs

Not able to override collapsible.js in magento 2

Sum array values

SlimExceptionHttpNotFoundException

PHP code for generating decent-looking coupon codes (mix of letters and numbers)

PHP error: "The zip extension and unzip command are both missing, skipping."

Select option menu read from database and use it's values

I want to display a sweetalert after the inserting of data in my database

Xdebug can't connect back to Docker host

image source not readable

Get WooCommerce product variation attribute terms in admin products general box

Trying to iterate over a mongodb cursor twice - failing

onKeyUp event calculation not working on the following rows from php generated forms except the first one

XML to CSV with PHP converter [problem with images grabing]

About Contact Privacy policy Terms and conditions