Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Closed Thread
str_replace not working as expected.
Old 01-09-2011, 02:59 AM str_replace not working as expected.
Webmaster Talker

Posts: 626
Trades: 0
It's been a while since dabbling in PHP. I'm editing the output of a module in Joomla. The module is a news module and I'm trying to get it to open in a lightbox.

I've got everything functioning as far as the lightbox goes, but in order to output the way I want, I need the link to be changed from index.php to index2.php.

URL: http://www.mysite.com/index.php?opti...ls&catid=9:u11

I want it to be: http://www.mysite.com/index2.php?opt...ls&catid=9:u11

For some reason the str_replace function is replacing the WHOLE string to be the new value instead of just searching and replacing the text within the string.

Here is what I've done:
Code:
		<a rel="rokbox[600 350]" href="<?php echo str_ireplace($item->link, 'index2.php', 'index.php'); ?>" class="latestnews<?php echo $params->get('pageclass_sfx'); ?>">
Can anyone help me with this please?
jim.thornton is offline
View Public Profile
 
 
Register now for full access!
Old 01-09-2011, 03:08 AM Re: str_replace not working as expected.
Webmaster Talker

Posts: 626
Trades: 0
Man... That was stupid!

I figured out that I had the ordering wrong for the function. I moved it around and it worked fine.
jim.thornton is offline
View Public Profile
 
Old 01-09-2011, 10:16 AM Re: str_replace not working as expected.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by jim.thornton View Post
Man... That was stupid!
I think every programmer in any language can empathise with that sentiment
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
View Public Profile Visit chrishirst's homepage!
 
Old 01-09-2011, 11:39 AM Re: str_replace not working as expected.
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
You appear to be suffering from the same issue I have.
After many hours of trying to debug an issue, I post here.

Only to read over my post and figure it out or to shortly figure it out afterwards.

Sometimes posting and not having any replys is the best way to fix an issue lol.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
View Public Profile Visit lynxus's homepage!
 
Old 01-09-2011, 02:30 PM Re: str_replace not working as expected.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Maybe we should a have "programmers memory jogging" section where you can post, not get repies and then re-read the post.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
View Public Profile Visit chrishirst's homepage!
 
Old 01-11-2011, 09:45 AM Re: str_replace not working as expected.
Banned

Posts: 1
Name: kemanblack
Trades: 0
The problem with the use of the app Settings is that the values of each setting can be achieved by using a key text and returns only the text. It 's much easier than from the developer to use objects as strings and do all kind of results yourself.
kemanblack is offline
View Public Profile
 
Closed Thread     « Reply to str_replace not working as expected.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 2.10345 seconds with 12 queries