0

I have this to make a file ... but the file created is only ever .php, it is like it is not echoing the field name.

$newfile ="" . str_replace(' ','-',trim($file['title'])) . ".php";

and the next one i tried to echo out in the page came out blank too?

<?php $txt1 = "'. $file['title'] . '"?>

Hope some one can help :)

2
Contributors
3
Replies
25
Views
3 Years
Discussion Span
Last Post by mpc123
1

You may want to make sure that $file['title'] actually has a value by just echoing it out echo $file['title'];.

If it doesn't have a value then the issue is most likely somewhere else before this when you created the array (assuming you prob created it off an upload from $_FILES). You'll probably need to show that code.

0

It just crossed my mind also, you might be interested in this function I posted a couple of days ago on my blog for turning a string into a slug.

function slugify($string){

    // trim off hyphens on ends of string
    $string = trim($string, '-');

    // replace all non-standard characters or numbers
    $string = preg_replace('~[^\\pL\d]+~u', '-', $string);

    // transliterate
    if(function_exists('transliterator_transliterate')){
        $string = transliterator_transliterate('Any-Latin; Latin-ASCII; Lower()', $string);
    }
    elseif(function_exists('iconv')){
        $string = iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $string);
    }

    // convert string to lowercase
    $string = strtolower($string);

    // remove unwanted characters
    $string = preg_replace('~[^-\w]+~', '', $string);

    // check if string is empty
    if (empty($string)){
        return 'n-a';
    }

    return $string;
}

http://oliverkelso.com/2014/02/17/slugify-a-string-with-php/

0

Hi thanks for your help i had set my result as $row instead of $file therefore there was no result

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.