Solved

PHP: Everything before Zooph

Posted on 2011-02-16
2
313 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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

680 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