I'm bulding an event calendar via fullcalendar.
i get the events from a php app that i wrote and i transfer them to the fullcalendar via json.
the problem is that when i try to escape the single quote, the fullcalendar does nor render at all.
here is the problamrtic line code:
foreach ($jsonEvent[$key1] as $key2 => $value2) {
if ($key2 == "title") {
$jsonEvent[$key1][$key2] = str_replace("'","\'", $value2); //this is the problamatic line code that if excecute the fullcalendar will not render
}
}
}
$jsonString = json_encode($jsonEvent);
when i dont try to escape the single quote, then the fullcalendar render just fine. like in tihs code:
foreach ($jsonEvent[$key1] as $key2 => $value2) {
if ($key2 == "title") {
$jsonEvent[$key1][$key2] = str_replace("'","", $value2); //with this line the fullcalendar render jus fine
}
}
}
$jsonString = json_encode($jsonEvent);
so, how can i escape the single quote(') and still get the full calendar to render?
FYI: here is the code for rendering the fullcalendar
<?php echo "<div id='calendar'></div>
<script>
var json = $json_array_for_fullCalendar; // this is the JSON array with the events
$('#calendar').fullCalendar({
events: json,
fixedWeekCount: false,
});
</script>"; ?>
can anyone please help? many thanks!