Q:

How do i make all the ' symbols into " while still detecting the variables in PHP? 

So I have this peice of code, the function is not relavant for the question
Samplefunction("fileDirectory", 23, "{ 'title': '.$PageTitle', 'url': '/.$PageTitle/' },");
In the row in bold, the line: "{ 'title': '.$PageTitle', 'url': '/.$PageTitle/' }," is a good and working line.  however since this is a sting in a function, currently the ' symbols have to be ". 
If i writ the line like so:
'{ "title": ".$PageTitle", "url": "/.$PageTitle/" },');
The string will be ok but the variables will be undetected. 
I need the string within to a " and not a ' but i also need the variables to be detected. 
Any suggestions on how to do this? 
Best Regards,
AT
My complete code:
$filedirectory = "/sample/file/directoy";

$PageTitle = "shop";
function textinjector($file, $linerNumber, $injText ) {

$content = file($file); //Read the file into an array.  Line number => line content
foreach($content as $lineNumber => &$lineContent) { //Loop through the array (the "lines")
    if($lineNumber == $linerNumber) { //Remember we start at line 0. 
        $lineContent .= $injText .  PHP_EOL; //Modify the line. ( We're adding another line by using PHP_EOL)

    } 
}

$allContent = implode("", $content); //Put the array back into one string
file_put_contents($file, $allContent); //Overwrite the file with the new content
echo "$injText was injected to $file at line number $lineNumber";
}

// insertTextAtLineNumber("$filedirectory", 20, "import $pagetitlecaps from './$PageTitle/index';");
textinjector("$filedirectory", 23, '{ "title": ".$PageTitle", "url": "/.$PageTitle/" },'); // inject text into the menu area 
? >

A:

You can change the way you generate the string by breaking the it up in to the separate parts (static and dynamic) and concatenating the parts together with . 
textinjector($filedirectory, 23, '{ "title": ".' .  $PageTitle . '", " url": "/.' .  $PageTitle . '/" },');