473,383 Members | 1,829 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,383 software developers and data experts.

Fonction STR_REPLACE

Bonjour

Je désire utiliser un str_replace sur une variable qui contient le
résultat d'une commande system().

Bizarrement le STR_REPLACE semble sans effet

exemple de mon code

$entree = system('ls') ;
$sortie = str_replace(".php","",$entree) ;
echo $sortie

Une idée du pourquoi ?

Sep 1 '06 #1
2 1438

al***********@gmail.com wrote:

First of all, this is an English-speaking newsgroup. Do not
expect answers speaking in any other language (you *could*
get an answer, just don't *expect* one; there's also a
significant drop in your chances to get a *helpful*
answer).
Je désire utiliser un str_replace sur une variable qui
contient le résultat d'une commande system().

Bizarrement le STR_REPLACE semble sans effet
There's nothing really 'bizarrement' about that. If only
you had read the docs, you would notice that system() is
described as follows: 'system -- Execute an external
program and display the output'.
exemple de mon code

$entree = system('ls') ;
$sortie = str_replace(".php","",$entree) ;
echo $sortie

Une idée du pourquoi ?
See above.

Okay, what you need is backticks.

$entree = `ls` ;

Next time, read the docs. There is even a French version of
PHP Manual if you want convenience, although I would advise
against using that.

--
Pavel Lepin

Sep 1 '06 #2
Thank you for your answer,

Just for your information, i've read the doc but as i'm just beginning
with php i don't understand everything as soon as i read the doc, sorry
for this.

Anyway, i still don't understand because if my variable stores the
result of the system output for me there's no difference with a text
string.

let's imagine the result of the ls command is "myfile.php", then what
is the difference between :

$brut = system('ls')
and
$brut = "myfile.ph"

I imagine it's easy for you but i can assure you that i've read the doc
and it still doesn't make sense for me.

Sep 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jon | last post by:
Why does the following not replace the ":)"? str_replace(":)", "&nbsp;<img src=http://www.com.com/forum/emoticons/smiley.gif>&nbsp;", $_POST); But, the following does replace the ":("? ...
9
by: Hugo Coolens | last post by:
I need to use the str_replace function for a php-script which works together with html/javascript. In the script I have to perform things like: $arabic=str_replace ("'","\'", $row);...
3
by: Philippe Mesmeur | last post by:
J'ai eu une longue discussion hier au sujet des parametres de fonction const. La personne etait pour mettre "const" devant TOUS les parametres ne devant pas etre modifies. A mon avis, il faut...
1
by: marcomputers | last post by:
Hi, I'm trying to automatically update an existing rss podcast file using php and the str_replace function. Every time I add a media file, it should read the .rss file into a string, take the...
9
by: Wayne | last post by:
$a = $_POST; # txt_content = This is a<CR><LF>Test $p = str_replace ("%0D%0A", "<br>", $a); That is the above code that I am using, however, it is not picking up the CR/LF from the textarea. I...
4
by: The Numerator | last post by:
I have this page (print.php). In that file, I want to to include a text file from "songs/breathe.txt", and replace all instances of "<b" with "<span" and "</b>" with "</span>". I know how I should...
4
by: d1srupt3r | last post by:
I am developing my form into a captcha secured form and I used header() function if the user didn't put the verification code properly and still when the user go back to the form page the filled he...
5
by: jmark | last post by:
I saw this example in php.net // Outputs: apearpearle pear $letters = array('a', 'p'); $fruit = array('apple', 'pear'); $text = 'a p'; $output = str_replace($letters, $fruit, $text);...
3
by: Confused but working on it | last post by:
So I've been trying to get a bit of code to: Read all of the files in a dir called thumbs, but not the . and .., use the filename in a link to get the same filename in an images dir. Now I'm...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.