| | |
str_replace help needed
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2009
Posts: 9
Reputation:
Solved Threads: 0
Hi,
I am using str_replace to scan through pages and replace, for example; [gallery] with the actual gallery page using an include command.
For example;
[gallery]
Once this is located it's replaced by
include('modules/gallery/index.php');
How can you do this (and for multiple ones, [gallery], [enquiry]?
Thank's very much.
Zack.
I am using str_replace to scan through pages and replace, for example; [gallery] with the actual gallery page using an include command.
For example;
[gallery]
Once this is located it's replaced by
include('modules/gallery/index.php');
How can you do this (and for multiple ones, [gallery], [enquiry]?
Thank's very much.
Zack.
•
•
Join Date: Sep 2009
Posts: 523
Reputation:
Solved Threads: 61
0
#4 29 Days Ago
PHP Syntax (Toggle Plain Text)
$str1 = array('[gallery]','[enquiry]'); $str2 = "include('modules/gallery/index.php');"; str_replace($str1, $str2, $target);
try to escape the '/' inside the string if it troubles
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
•
•
Join Date: Sep 2009
Posts: 9
Reputation:
Solved Threads: 0
0
#5 29 Days Ago
Hi,
This is the current code concept i have come up with:
Say i use the [gallery] tag, it just displays;
include('modules/gallery/index.php')
Zack
This is the current code concept i have come up with:
PHP Syntax (Toggle Plain Text)
$code = $pager['code']; $block = array("[gallery]", "[enquiry]"); $replace = array("include('modules/gallery/index.php')", "include('modules/enquiry/index.php')"); $replaced_code = str_replace($block, $replace, $code); echo $replaced_code;
Say i use the [gallery] tag, it just displays;
include('modules/gallery/index.php')
Zack
Last edited by Zack_G; 29 Days Ago at 7:31 am.
•
•
Join Date: Oct 2009
Posts: 15
Reputation:
Solved Threads: 3
0
#6 29 Days Ago
PHP Syntax (Toggle Plain Text)
<?php $file_path = "gallery/index.php"; /* First Include Gallery Module */ include ($file_path); /* Replace Gallery Module to Enquiry Module */ $file_path = str_replace("gallery","enquiry",$file_path); /* First Include Gallery Module */ include ($file_path); ?>
•
•
Join Date: Oct 2009
Posts: 15
Reputation:
Solved Threads: 3
0
#7 29 Days Ago
PHP Syntax (Toggle Plain Text)
<?php $file_path = "gallery/index.php"; /* First Include Gallery Module */ include ($file_path); /* Replace Gallery Module to Enquiry Module */ $file_path = str_replace("gallery","enquiry",$file_path); /* First Include Gallery Module */ include ($file_path); ?>
•
•
Join Date: Sep 2009
Posts: 523
Reputation:
Solved Threads: 61
0
#9 29 Days Ago
go ahead with your code, it should work, similar as mine
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
![]() |
Similar Threads
- How to export data from mysql into fields in excell (PHP)
- Cannot modify header information.Headers already sent (PHP)
- Harddrive failure and 100% CPU under Win2K, Help Needed! (Windows NT / 2000 / XP)
- XP PRO iis help needed (Windows NT / 2000 / XP)
- CWS. help needed (Viruses, Spyware and other Nasties)
- are all these needed (Windows NT / 2000 / XP)
- help much needed !! (OS X)
Other Threads in the PHP Forum
- Previous Thread: Validation in Zend Framework Not working in Index Controller
- Next Thread: Php mysql image scroll script??
| Thread Tools | Search this Thread |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions simple sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube





