Simple Question I Think

Discussion in 'PHP' started by geekazoid, Jul 10, 2006.

  1. #1
    By using php i would like to be able to edit 3 words just by editing the first word

    So lets say my first word is cheese and elsewhere on the page cheese is in two other places... When i edit this word to maybe bacon.. it also changes the 2 other words from cheese to bacon on my page automaticaly saving me decades

    Does anyone know how to do this ?
     
    geekazoid, Jul 10, 2006 IP
  2. ahref

    ahref Well-Known Member

    Messages:
    1,123
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    170
    #2
    create a variable and $item assign value cheese to $item. Use $item instead of cheese in your page.
     
    ahref, Jul 10, 2006 IP
  3. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If your content is in $data and echoing the whole page is something like echo $data then you can easily replace cheese with bacon with str_replace:

    
    $data = str_replace($data, 'cheese', 'bacon'); //check syntax on php.net though...
    
    
    PHP:
     
    T0PS3O, Jul 10, 2006 IP
  4. geekazoid

    geekazoid Peon

    Messages:
    208
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ahref Thats exactly what i was looking for but could you show me how to do it please ?
     
    geekazoid, Jul 10, 2006 IP
  5. DaVe™

    DaVe™ Peon

    Messages:
    347
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Tops's way is probably a bit easier,

    using ahref you will have to go and change 'cheese' first of all to '$data'. So if your willing to do that, why not just change them all to bacon?
     
    DaVe™, Jul 10, 2006 IP
  6. geekazoid

    geekazoid Peon

    Messages:
    208
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    because i want to change them on 300 pages to differant things not all to bacon, i want to change some from cheese to ivory and some from cheese to pirates.
     
    geekazoid, Jul 10, 2006 IP
  7. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Randomize it then. Put bacon, ivory and pirates in an array and then randomly pick one to replace cheese with.
     
    T0PS3O, Jul 10, 2006 IP
  8. geekazoid

    geekazoid Peon

    Messages:
    208
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I dont want to do it randomly, sorry i cant be making myself very clear.

    All i want is something like this

    <?php
    $term1 = "Cheese";
    ?>

    and then a script to be able to past that into my title and else where on the page so i can edit it in design mode and not to have to go into code.
     
    geekazoid, Jul 10, 2006 IP
  9. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I think you need to stop using dreamweaver and start using a proper php editor. Try crimson editor.
     
    mad4, Jul 11, 2006 IP
  10. geekazoid

    geekazoid Peon

    Messages:
    208
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Whats wrong with good old dreamweaver ?
     
    geekazoid, Jul 11, 2006 IP
  11. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Its confusing for php code. Switch to crimson and you will never go back. Just trust me on this one. :)
     
    mad4, Jul 12, 2006 IP