473,395 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

replace content of object

110 100+
I've been looking through the object documentation, but can't seem to figure out how to do a str_replace type function on an object variable.

I'm using Troy Wolf's class_http.php - in an iframe to output the content of a 3rd party site.
I am trying to 'inject' another stylesheet into this iframe so that it works along with my site (in case anybody is concerned, fair use copyrights are being protected).

I can see the object body as
Expand|Select|Wrap|Line Numbers
  1. // Send the response body to the client.
  2. print_r(get_object_vars($h));
  3. echo $h->body;
  4.  
I've put the print_r just so I can see what the object spits out. and the last object is [body]. I tried interacting with body as $h['body'], but got a message that I can't interact with the object like that.

What I am trying to do is
Expand|Select|Wrap|Line Numbers
  1. $h['body'] = str_replace("<\/title>", "<\/title><link rel=\"stylesheet\" type=\"text/css\" href=\"http://localhost/repair.css\" />", $h['body']);
but of course, that doesn't work simply.

Any ideas?
Nov 5 '07 #1
2 2281
Atli
5,058 Expert 4TB
Hi.

If the $h->body member is a public member you should simply be able to do this:
Expand|Select|Wrap|Line Numbers
  1. $h->body = str_replace("</title>", "</title><link rel=\"stylesheet\" type=\"text/css\" href=\"http://localhost/repair.css\" />", $h->body);
  2.  
Nov 5 '07 #2
pedalpete
110 100+
Once again Atli, thank you.

Your infinite knowledge has a propensity for making me look silly!

I have know idea what a "public member" is, but of course, your code works perfectly.

Thanks again,
Pete
Nov 5 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Barnes | last post by:
Does anyone know of a good way to use the JavaScript string.replace() method in an ASP form? Here is the scenario: I have a form that cannot accept apostrophes. I want to use the replace() so...
2
by: KennethSoona | last post by:
content=Regex.Replace(content, @"/*Offline*/", @"//Offline"); content=Regex.Replace(content, @"//Online", @"/*Online*/"); Second line works fine but the first didn't! I think the problem are the...
15
by: tshad | last post by:
How do I go about this? I used to know this, but can't find VB.net replace that does this. Something like string.replace("<br>",NL) Thanks,
3
by: Andy Sutorius | last post by:
Hi, I read the thread (2/16/05) regarding a replace function in C# however it didn't answer my question. I have a string which is building an insert sql statement and I would like to replace...
4
by: Neo Geshel | last post by:
Greetings I am using VB in my ASP.NET project that uses an admin web site to populate a database that provides content for a front end web site. I am looking for a way to use replace() to...
5
by: Casey | last post by:
Hello, Can someone give me specific code to replace text on a page using server side javascript? I need to use server-side because I need the output to be recognized in the final HTML so that...
7
by: .... | last post by:
Hi I have an existing function which has a stream object (inmsg.BodyPart.Data). I'm trying to search and replace the stream object in the most efficient way possible This is my attempt below,...
4
by: ICPooreMan | last post by:
I've got some code which works in firefox that's giving me fits in IE7 (maybe other versions too I haven't tested it). What I want to do is get the oncontextmenu attribute of something, change the...
6
by: Rauan Maemirov | last post by:
Hi, all. I'm trying to replace <object ...><embed... /></objectwith <imgtag and vice-verse. It's like implementation of media plugin of Tiny MCE editor. I tried to watch their code, but it's too...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.