Solved

PHP: Everything before Zooph

Posted on 2011-02-16
2
314 Views
Last Modified: 2012-05-11
I want a string to contain everything before " Zooph"

So:
Hello, World! Zooph 123

Should become:
Hello, World!
0
Comment
Question by:hankknight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
rationalboss earned 300 total points
ID: 34912631
$word = ' Zooph';
$data = 'Hello, world! Zooph 123';

$exp = explode($word,$data);
echo $exp[0];

Open in new window

0
 
LVL 34

Assisted Solution

by:Beverley Portlock
Beverley Portlock earned 200 total points
ID: 34914034
Another way....

<?php

$word = ' Zooph';
$data = 'Hello, world! Zooph 123';

echo preg_replace('#(.*)'.$word.'.*#is', '$1', $data );

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question