|
Posted by dkirkdrei on 09/22/07 19:04
On Sep 22, 2:43 pm, "Steve" <no....@example.com> wrote:
> <dkirkd...@yahoo.com> wrote in message
>
> news:1190475589.522207.39050@o80g2000hse.googlegroups.com...
>
>
>
>
>
> > On Sep 22, 11:29 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> >> dkirkd...@yahoo.com wrote:
> >> > On Sep 22, 10:40 am, gosha bine <stereof...@gmail.com> wrote:
> >> >> dkirkd...@yahoo.com wrote:
> >> >>> On Sep 22, 4:28 am, gosha bine <stereof...@gmail.com> wrote:
> >> >>>> dkirkd...@yahoo.com wrote:
> >> >>>>> I am having a bit of trouble trying to double up on slashes in a
> >> >>>>> file
> >> >>>>> path. What I am trying to do is very similar to the code below:
> >> >>>>> <?
> >> >>>>> $var = "\\wusais\Intranets\Intranets\fpdb\pdf\weinig\00505882.pdf";
> >> >>>>> $new = preg_replace("\\", "\\\", "$var");
> >> >>>>> ?>
> >> >>>>> Code above produces the following error:
> >> >>>>> Parse error: parse error, unexpected T_VARIABLE in
> >> >>>>> c:\Inetpub\wwwroot
> >> >>>>> \pages\replace.php on line 12
> >> >>>>> In the end, $new needs to be:
> >> >>>>> \\\\wusais\\Intranets\\Intranets\\fpdb\
> >> >>>>> \pdf\\weinig\\00505882.pdf
> >> >>>>> but it seems to be very difficult replacing slashes.
> >> >>>>> Any help would be greatly appreciated
> >> >>>> $var =
> >> >>>> "\\wusais\\Intranets\\Intranets\\fpdb\\pdf\\weinig\\00505882.pdf";
> >> >>>> echo strtr($var, array('\\' => '\\\\'));
> >> >>>> note that initially $var actually contains only single slashes,
> >> >>>> however
> >> >>>> you must write each slash twice because of php escaping rules.
> >> >>>> --
> >> >>>> gosha bine
> >> >>>> extended php parser ~http://code.google.com/p/pihipi
> >> >>>> blok ~http://www.tagarga.com/blok-Hidequotedtext -
> >> >>>> - Show quoted text -
> >> >>> These file paths are coming from a database, they are all windows
> >> >>> paths and they reside on a company intranet so it is a "controlled"
> >> >>> environment. Every file path is structured just like
> >> >>> \\wusais\Intranets
> >> >>> \Intranets\fpdb\pdf\weinig\00505882.pdf. For what I am trying to do,
> >> >>> I
> >> >>> have to double up on all of the slashes which is really being a pain.
> >> >>> At this point, I believe I am going to try and explode the string to
> >> >>> remove all the slashes and then reassemble it with the correct number
> >> >>> of slashes.
> >> >> This doesn't matter where the string comes from. The code I posted
> >> >> above
>
> >> >> $var = strtr($var, array('\\' => '\\\\'));
>
> >> >> should work for the strings coming from the database as well.
>
> >> >> --
> >> >> gosha bine
>
> >> >> extended php parser ~http://code.google.com/p/pihipi
> >> >> blok ~http://www.tagarga.com/blok-Hidequoted text -
>
> >> >> - Show quoted text -
>
> >> > the code:
>
> >> > <?
> >> > $var = "\\wusais\Intranets\Intranets\fpdb\pdf\weinig\00505882.pdf";
> >> > echo strtr($var, array('\\' => '\\\\'));
> >> > ?>
>
> >> > produces this:
>
> >> > \\wusais\\Intranets\\Intranets\\fpdb\\pdf\\weinig 05882.pdf
>
> >> > close but the end is still killing me...
>
> >> That's because your starting string is NOT VALID! See my post above.
>
> >> Get the string from the database and try parsing it. You'll get a much
> >> different result.
>
> >> --
> >> ==================
> >> Remove the "x" from my email address
> >> Jerry Stuckle
> >> JDS Computer Training Corp.
> >> jstuck...@attglobal.net
> >> ==================- Hide quoted text -
>
> >> - Show quoted text -
>
> > My problem is that the string coming from the database as variable
> > with 2 slashes in the front and 1 slash between each directory. Once
> > the variable comes from the db, I am passing it on to a javascript. If
> > I pass the variable as is, the script will not work but if I double up
> > on the slashes everything works fine. So, I have to take the file path
> > that is coming out of the db and double up on the slashes. Using only
> > php, everything works fine with the slashes the way they are.
>
> gotcha...it's just hard to express for the purposes of posting here what
> jerry would consider a *valid* string (whatever that means), so that we have
> something to work with. is that about right?- Hide quoted text -
>
> - Show quoted text -
I still have not figured out a way to turn this:
$var = "\\wusais\Intranets\Intranets\fpdb\pdf\weinig\00505882.pdf";
into this using php:
$var = "\\\\wusais\\Intranets\\Intranets\\fpdb\\pdf\\weinig\
\00505882.pdf";
Navigation:
[Reply to this message]
|