For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > September 2004 > viarable converting...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author viarable converting...
Grzegorz R

2004-09-28, 9:26 pm

How I can convert variable $one="index.html" into variable
$two="indexhtml" or $two="index" something without point or only te first
word . The varabile is a string.


Harrie Verveer

2004-09-29, 4:57 am

There are s lot of ways to do so. Here are a few:

$one = "index.html";
$two = explode(".","index.html");
echo ($two[0]); // "index"
echo ($two[1]); // "html"
--------------------------------------- OR
$one = "index.html";
$two = str_replace(".","",$one);
echo $two; // "indexhtml"
--------------------------------------- OR
$one = "index.html";
$pos = strpos($one,".");
$two = substr($one,0,$pos);
$three = substr($one,$pos+1);

and I'm sure there are a lot of other ways :)

Good Luck!

Harrie

Grzegorz R wrote:
> How I can convert variable $one="index.html" into variable
> $two="indexhtml" or $two="index" something without point or only te first
> word . The varabile is a string.
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com