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 :)

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.

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
        $string = transliterator_transliterate('Any-Latin; Latin-ASCII; Lower()', $string);
        $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;


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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.